diff mbox series

[FFmpeg-devel,2/9] avformat/asf: Check picsize

Message ID 20240919225639.2376418-2-michael@niedermayer.cc
State New
Headers show
Series None | expand

Commit Message

Michael Niedermayer Sept. 19, 2024, 10:56 p.m. UTC
Fixes: signed integer overflow: 1073750247 * 2 cannot be represented in type 'int'
Fixes: 70722/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-5447231587549184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/asf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/asf.c b/libavformat/asf.c
index a71337aa3c9..5c118d2dbe0 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -90,8 +90,8 @@  static int asf_read_picture(AVFormatContext *s, int len)
         return 0;
     }
 
-    if (picsize >= len) {
-        av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d >= %d.\n",
+    if (picsize >= len || ((int64_t)len - picsize) * 2 + 1 > INT_MAX) {
+        av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d  (len = %d).\n",
                picsize, len);
         return AVERROR_INVALIDDATA;
     }