[FFmpeg-devel] [PATCH 3/4] avformat/mccdec: Fix overflows in num/den

Michael Niedermayer michael at niedermayer.cc
Sat Apr 24 18:59:25 EEST 2021


Fixes: signed integer overflow: 6365816 * 1000 cannot be represented in type 'int'
Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_MCC_fuzzer-6737934184218624

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/mccdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
index 2a0b7905a0..7671be61d4 100644
--- a/libavformat/mccdec.c
+++ b/libavformat/mccdec.c
@@ -127,8 +127,7 @@ static int mcc_read_header(AVFormatContext *s)
                 num = strtol(rate_str, &df, 10);
                 den = 1;
                 if (df && !av_strncasecmp(df, "DF", 2)) {
-                    num *= 1000;
-                    den  = 1001;
+                    av_reduce(&num, &den, num * 1000LL, 10001, INT_MAX);
                 }
             }
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list