]> git.sesse.net Git - ffmpeg/commitdiff
avformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 17 Oct 2020 21:50:57 +0000 (23:50 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 30 Oct 2020 16:49:51 +0000 (17:49 +0100)
Fixes: OOM
Fixes: 26414/clusterfuzz-testcase-minimized-ffmpeg_dem_FWSE_fuzzer-5070632544632832
Fixes: 26475/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5770207722995712
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/wavdec.c

index bca186a66f6941dc2b1e1264da9ecc5e16737d3b..a81f2c7a6798174dcd02be1da3087b8ba9ba32c4 100644 (file)
@@ -902,6 +902,7 @@ static int w64_read_header(AVFormatContext *s)
         } else if (!memcmp(guid, ff_w64_guid_summarylist, 16)) {
             int64_t start, end, cur;
             uint32_t count, chunk_size, i;
+            int64_t filesize  = avio_size(s->pb);
 
             start = avio_tell(pb);
             end = start + FFALIGN(size, INT64_C(8)) - 24;
@@ -916,7 +917,7 @@ static int w64_read_header(AVFormatContext *s)
                 chunk_key[4] = 0;
                 avio_read(pb, chunk_key, 4);
                 chunk_size = avio_rl32(pb);
-                if (chunk_size == UINT32_MAX)
+                if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
                     return AVERROR_INVALIDDATA;
 
                 value = av_mallocz(chunk_size + 1);