diff mbox series

[FFmpeg-devel,3/4] avformat/wavdec: More complete size check in find_guid()

Message ID 20201114222628.6486-3-michael@niedermayer.cc
State Accepted
Commit a207df2acb92d6366ab2f0f18ba35709066b8eec
Headers show
Series [FFmpeg-devel,1/4] avformat/iff: Check size before skip | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Nov. 14, 2020, 10:26 p.m. UTC
Fixes: signed integer overflow: 9223372036854775807 + 8 cannot be represented in type 'long'
Fixes: 27341/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5442833206738944

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index a81f2c7a67..df6030a42d 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -666,7 +666,7 @@  static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
     while (!avio_feof(pb)) {
         avio_read(pb, guid, 16);
         size = avio_rl64(pb);
-        if (size <= 24)
+        if (size <= 24 || size > INT64_MAX - 8)
             return AVERROR_INVALIDDATA;
         if (!memcmp(guid, guid1, 16))
             return size;