]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mov: Check a.size before computing next_root_atom
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 28 Nov 2020 20:20:43 +0000 (21:20 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 18 Jan 2021 23:05:50 +0000 (00:05 +0100)
Fixes: signed integer overflow: 64 + 9223372036854775799 cannot be represented in type 'long'
Fixes: 27563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6244650163372032
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 3215b536362263f12e8c6c750293e2161911ad9f..ad0b9a58d3568219ab3cdebe9e4bc323ad1f574b 100644 (file)
@@ -7071,7 +7071,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
                 c->atom_depth --;
                 return err;
             }
-            if (c->found_moov && c->found_mdat &&
+            if (c->found_moov && c->found_mdat && a.size <= INT64_MAX - start_pos &&
                 ((!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->frag_index.complete) ||
                  start_pos + a.size == avio_size(pb))) {
                 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || c->fc->flags & AVFMT_FLAG_IGNIDX || c->frag_index.complete)