]> git.sesse.net Git - ffmpeg/commitdiff
avformat/dhav: Check position for overflow
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 3 Dec 2020 23:30:12 +0000 (00:30 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 8 Jan 2021 17:08:57 +0000 (18:08 +0100)
Fixes: signed integer overflow: 9223372036854775807 + 32768 cannot be represented in type 'long'
Fixes: 27744/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5179319491756032
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/dhav.c

index 53deaff77eb91eb89a5f10f16d90f998193ca3f5..00e0d8476e4166e27f541ec5e614d1d4839226e2 100644 (file)
@@ -173,12 +173,12 @@ static int read_chunk(AVFormatContext *s)
     if (avio_feof(s->pb))
         return AVERROR_EOF;
 
-    if (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
+    if (avio_rl32(s->pb) != MKTAG('D','H','A','V') && dhav->last_good_pos < INT64_MAX - 0x8000) {
         dhav->last_good_pos += 0x8000;
         avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
 
         while (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
-            if (avio_feof(s->pb))
+            if (avio_feof(s->pb) || dhav->last_good_pos >= INT64_MAX - 0x8000)
                 return AVERROR_EOF;
             dhav->last_good_pos += 0x8000;
             ret = avio_skip(s->pb, 0x8000 - 4);