aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Aimar <fenrir@videolan.org>2011-09-11 23:26:12 +0200
committerReinhard Tartler <siretart@tauware.de>2011-09-26 19:26:33 +0200
commita3d471e500674c31fa4f52a62ef789d5e7fdbd3c (patch)
tree5af029e02bdf93f87860305ab868619f40d13c77
parent54a178f28ff5caf8cac5493cc3f1c22ac2323fcf (diff)
downloadffmpeg-a3d471e500674c31fa4f52a62ef789d5e7fdbd3c.tar.gz
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@gentoo.org> (cherry picked from commit 0e7efb9d23c3641d50caa288818e8c27647ce74d) Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r--libavformat/oggdec.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 25f5cd8b2d..18201677b8 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);