avcodec/apedec: Use 64bit to avoid overflow

Fixes: runtime error: signed integer overflow: 727298502 * 3 cannot be represented in type 'int'
Fixes: 39172/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-638602483033702

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f059b56195)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-09-29 20:53:53 +02:00
parent 9236882745
commit 3c81d7025e
1 changed files with 1 additions and 1 deletions

View File

@ -1286,7 +1286,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
absres = res < 0 ? -(unsigned)res : res; absres = res < 0 ? -(unsigned)res : res;
if (absres) if (absres)
*f->adaptcoeffs = APESIGN(res) * *f->adaptcoeffs = APESIGN(res) *
(8 << ((absres > f->avg * 3) + (absres > (f->avg + f->avg / 3)))); (8 << ((absres > f->avg * 3LL) + (absres > (f->avg + f->avg / 3))));
/* equivalent to the following code /* equivalent to the following code
if (absres <= f->avg * 4 / 3) if (absres <= f->avg * 4 / 3)
*f->adaptcoeffs = APESIGN(res) * 8; *f->adaptcoeffs = APESIGN(res) * 8;