Commit 13171ad2 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/rv40dsp: Fix integer overflows in rv40_weight_func_*()

Fixes: signed integer overflow: 40550400 * 128 cannot be represented in type 'int'
Fixes: 20331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV40_fuzzer-5676685725007872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 2a322906
...@@ -385,7 +385,7 @@ static void rv40_weight_func_rnd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t ...@@ -385,7 +385,7 @@ static void rv40_weight_func_rnd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t
\ \
for (j = 0; j < size; j++) {\ for (j = 0; j < size; j++) {\
for (i = 0; i < size; i++)\ for (i = 0; i < size; i++)\
dst[i] = (((w2 * src1[i]) >> 9) + ((w1 * src2[i]) >> 9) + 0x10) >> 5;\ dst[i] = ((((unsigned)w2 * src1[i]) >> 9) + (((unsigned)w1 * src2[i]) >> 9) + 0x10) >> 5;\
src1 += stride;\ src1 += stride;\
src2 += stride;\ src2 += stride;\
dst += stride;\ dst += stride;\
...@@ -397,7 +397,7 @@ static void rv40_weight_func_nornd_ ## size (uint8_t *dst, uint8_t *src1, uint8_ ...@@ -397,7 +397,7 @@ static void rv40_weight_func_nornd_ ## size (uint8_t *dst, uint8_t *src1, uint8_
\ \
for (j = 0; j < size; j++) {\ for (j = 0; j < size; j++) {\
for (i = 0; i < size; i++)\ for (i = 0; i < size; i++)\
dst[i] = (w2 * src1[i] + w1 * src2[i] + 0x10) >> 5;\ dst[i] = ((unsigned)w2 * src1[i] + (unsigned)w1 * src2[i] + 0x10) >> 5;\
src1 += stride;\ src1 += stride;\
src2 += stride;\ src2 += stride;\
dst += stride;\ dst += stride;\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment