lavf/mov.c: Avoid heap allocation wraps in mov_read_{senc,saiz}() n3.0.7
authorMatt Wolenetz <wolenetz@google.com>
Wed, 14 Dec 2016 23:27:49 +0000 (15:27 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 10 Feb 2017 11:16:24 +0000 (12:16 +0100)
Core of patch is from paul@paulmehta.com
Reference https://crbug.com/643952 (senc,saiz portions)

Signed-off-by: Matt Wolenetz <wolenetz@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 36aba43bd5fae8595dd9a566fbcfbbea63f0fca3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 6fc792f..b06e9c8 100644 (file)
@@ -4064,8 +4064,8 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     avio_rb32(pb);        /* entries */
 
-    if (atom.size < 8) {
-        av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" too small\n", atom.size);
+    if (atom.size < 8 || atom.size > FFMIN(INT_MAX, SIZE_MAX)) {
+        av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" invalid\n", atom.size);
         return AVERROR_INVALIDDATA;
     }