aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-10-17 23:50:57 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-11 21:23:48 +0200
commit633f4568be8ac67da7252dd33e304f3a239c20c2 (patch)
tree3fa97fddf24181eb017985680b6476405c9d9b89
parent92aece7e5a56c1cc6f2c2cffcd5845e3bfe5ff67 (diff)
downloadffmpeg-633f4568be8ac67da7252dd33e304f3a239c20c2.tar.gz
avformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()
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> (cherry picked from commit 7b2244565ac8cb1eddd085e1a382a893ac03bfb4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/wavdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 22150f63e9..1bb987f47b 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -835,6 +835,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;
@@ -849,7 +850,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);