]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mxfdec: Fix integer overflow in next position in mxf_read_local_tags()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 21 Jan 2021 20:41:41 +0000 (21:41 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 23 Jan 2021 00:05:25 +0000 (01:05 +0100)
Fixes: signed integer overflow: 9223372036854775723 + 8192 cannot be represented in type 'long'
Fixes: 29072/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4812604904177664
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mxfdec.c

index 4c932e954cc072fc13beddfaf84b6a381d6ffd31..afff20402ddf6eb698e415cb4a796e296db4eda6 100644 (file)
@@ -2865,8 +2865,11 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
         int ret;
         int tag = avio_rb16(pb);
         int size = avio_rb16(pb); /* KLV specified by 0x53 */
-        uint64_t next = avio_tell(pb) + size;
+        int64_t next = avio_tell(pb);
         UID uid = {0};
+        if (next < 0 || next > INT64_MAX - size)
+            return next < 0 ? next : AVERROR_INVALIDDATA;
+        next += size;
 
         av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size);
         if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */