aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-08-23 00:23:52 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-11 20:18:47 +0100
commitb718098a1e88e6b6640a3e638d149145d836834f (patch)
treeec42197fb2827121da9cc59763326e099ad366ac
parent033013f83d6dfa7259c004015feb694907235bcd (diff)
downloadffmpeg-b718098a1e88e6b6640a3e638d149145d836834f.tar.gz
avcodec/mpeg4videodec: Fix integer overflow in mpeg4_decode_studio_block()
Fixes: signed integer overflow: 24023040 * 112 cannot be represented in type 'int' Fixes: 16570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5173275211071488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Kieran Kunhya <kierank@obe.tv> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 0e4a0e962cb0e422d2a350b875fc1e38d7b842a3) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/mpeg4videodec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c9823807b5..e1ab9aac3a 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1824,6 +1824,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
uint32_t flc;
const int min = -1 * (1 << (s->avctx->bits_per_raw_sample + 6));
const int max = ((1 << (s->avctx->bits_per_raw_sample + 6)) - 1);
+ int shift = 3 - s->dct_precision;
mismatch = 1;
@@ -1919,7 +1920,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
else
block[j] = flc;
}
- block[j] = ((8 * 2 * block[j] * quant_matrix[j] * s->qscale) >> s->dct_precision) / 32;
+ block[j] = ((block[j] * quant_matrix[j] * s->qscale) * (1 << shift)) / 16;
block[j] = av_clip(block[j], min, max);
mismatch ^= block[j];
}