[FFmpeg-cvslog] oggdec: fix out of bound write in the ogg demuxer

Laurent Aimar git at videolan.org
Sat Sep 17 22:45:11 CEST 2011


ffmpeg | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Sep 11 23:26:12 2011 +0200| [0e7efb9d23c3641d50caa288818e8c27647ce74d] | committer: Luca Barbato

oggdec: fix out of bound write in the ogg demuxer

Between ogg_save() and ogg_restore() calls, the number of streams
could have been reduced.

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e7efb9d23c3641d50caa288818e8c27647ce74d
---

 libavformat/oggdec.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 3d03a5f..85f7ec7 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -92,14 +92,24 @@ static int ogg_restore(AVFormatContext *s, int discard)
     ogg->state = ost->next;
 
     if (!discard){
+        struct ogg_stream *old_streams = ogg->streams;
+
         for (i = 0; i < ogg->nstreams; i++)
             av_free (ogg->streams[i].buf);
 
         avio_seek (bc, ost->pos, SEEK_SET);
         ogg->curidx = ost->curidx;
         ogg->nstreams = ost->nstreams;
-        memcpy(ogg->streams, ost->streams,
-               ost->nstreams * sizeof(*ogg->streams));
+        ogg->streams = av_realloc (ogg->streams,
+                                   ogg->nstreams * sizeof (*ogg->streams));
+
+        if (ogg->streams) {
+            memcpy(ogg->streams, ost->streams,
+                   ost->nstreams * sizeof(*ogg->streams));
+        } else {
+            av_free(old_streams);
+            ogg->nstreams = 0;
+        }
     }
 
     av_free (ost);



More information about the ffmpeg-cvslog mailing list