]> git.sesse.net Git - ffmpeg/commitdiff
mov: Check the entries value when parsing dref boxes
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 8 Mar 2016 10:57:16 +0000 (11:57 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 11 Mar 2016 13:29:13 +0000 (14:29 +0100)
And properly reset the entries count when resetting the entries.

CC: libav-stable@libav.org
Bug-Id: 929
Bug-Id: CVE-2016-3062

libavformat/mov.c

index a556aa75dff3528844ee7626c42924e3b5bfd8eb..9d271f89747f4ecffef801fa71311de824bb3617 100644 (file)
@@ -473,9 +473,11 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     avio_rb32(pb); // version + flags
     entries = avio_rb32(pb);
-    if (entries >  (atom.size - 1) / MIN_DATA_ENTRY_BOX_SIZE + 1 ||
+    if (!entries ||
+        entries >  (atom.size - 1) / MIN_DATA_ENTRY_BOX_SIZE + 1 ||
         entries >= UINT_MAX / sizeof(*sc->drefs))
         return AVERROR_INVALIDDATA;
+    sc->drefs_count = 0;
     av_free(sc->drefs);
     sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
     if (!sc->drefs)