]> git.sesse.net Git - ffmpeg/commitdiff
avformat/wtvdec: Check size in SBE2_STREAM_DESC_EVENT / stream2_guid
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 3 Mar 2021 23:30:45 +0000 (00:30 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 29 Mar 2021 20:19:39 +0000 (22:19 +0200)
Fixes: signed integer overflow: 539033600 - -1910497124 cannot be represented in type 'int'
Fixes: 30928/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5922630966312960
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/wtvdec.c

index 7def9d23481f14ec66cc7b520d9e86ac3427359a..4b3b7fb407bc946c7289b5f2d9036f1322c3a307 100644 (file)
@@ -817,6 +817,8 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
                 avio_skip(pb, 12);
                 ff_get_guid(pb, &formattype);
                 size = avio_rl32(pb);
+                if (size < 0 || size > INT_MAX - 92)
+                    return AVERROR_INVALIDDATA;
                 parse_media_type(s, 0, sid, mediatype, subtype, formattype, size);
                 consumed += 92 + size;
             }
@@ -831,6 +833,8 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
                 avio_skip(pb, 12);
                 ff_get_guid(pb, &formattype);
                 size = avio_rl32(pb);
+                if (size < 0 || size > INT_MAX - 76)
+                    return AVERROR_INVALIDDATA;
                 parse_media_type(s, s->streams[stream_index], sid, mediatype, subtype, formattype, size);
                 consumed += 76 + size;
             }