[FFmpeg-devel] [PATCH 2/2] avformat/swfdec: Check outlen before allocation

Michael Niedermayer michael at niedermayer.cc
Fri Jan 22 16:09:47 EET 2021


Fixes: Timeout (too long -> 241ms)
Fixes: 29083/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-6273684478230528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/swfdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 1463f0ad4d..aa4be88f91 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -367,6 +367,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
             ff_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
                     ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
 
+            if (len * 17373LL < out_len)
+                goto bitmap_end_skip;
+
             zbuf = av_malloc(len);
             if (!zbuf) {
                 res = AVERROR(ENOMEM);
-- 
2.17.1



More information about the ffmpeg-devel mailing list