[FFmpeg-devel] [PATCH 2/5] avcodec/vc1: Fix overflow in aspect ratio calculation

Michael Niedermayer michael at niedermayer.cc
Fri Aug 9 02:23:47 EEST 2019


Fixes: signed integer overflow: 393215 * 14594 cannot be represented in type 'int'
Fixes: 15728/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5661588893204480

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

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index e102b931d8..0790eb160e 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -453,8 +453,8 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
         } else {
             av_reduce(&v->s.avctx->sample_aspect_ratio.num,
                       &v->s.avctx->sample_aspect_ratio.den,
-                      v->s.avctx->height * w,
-                      v->s.avctx->width * h,
+                      v->s.avctx->height * (int64_t)w,
+                      v->s.avctx->width * (int64_t)h,
                       1 << 30);
         }
         ff_set_sar(v->s.avctx, v->s.avctx->sample_aspect_ratio);
-- 
2.22.0



More information about the ffmpeg-devel mailing list