[0.8,1/2] mov: Check the entries value when parsing dref boxes

Message ID 1475670828-21115-1-git-send-email-diego@biurrun.de
State Superseded
Headers show

Commit Message

Diego Biurrun Oct. 5, 2016, 12:33 p.m.
From: Luca Barbato <lu_zero@gentoo.org>

And properly reset the entries count when resetting the entries.

CC: libav-stable@libav.org

Bug-Id: 929
Bug-Id: CVE-2016-3062
(cherry picked from commit 7e01d48cfd168c3dfc663f03a3b6a98e0ecba328)
Signed-off-by: Diego Biurrun <diego@biurrun.de>
---
 libavformat/mov.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a1de652..4e636e7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -387,8 +387,10 @@  static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     avio_rb32(pb); // version + flags
     entries = avio_rb32(pb);
-    if (entries >= UINT_MAX / sizeof(*sc->drefs))
+    if (!entries ||
+        entries >= UINT_MAX / sizeof(*sc->drefs))
         return AVERROR_INVALIDDATA;
+    sc->drefs_count = 0;
     sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
     if (!sc->drefs)
         return AVERROR(ENOMEM);