1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/adpcm: Fix integer overflow in intermediate in ADPCM_XMD

Fixes: runtime error: signed integer overflow: 2140143616 + 254665816 cannot be represented in type 'int'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_XMD_fuzzer-6690181676924928

As a sideeffect this simplifies the equation, the high bits are different after this but only
the low 16bits are stored and used in later steps.

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2023-04-16 13:52:32 +02:00
parent 8f0e200a12
commit 722ff74055
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -1579,11 +1579,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
nibble[0] = sign_extend(byte & 15, 4);
nibble[1] = sign_extend(byte >> 4, 4);
out[2+n*2] = (nibble[0]*(scale<<14) + (history[0]*29336) - (history[1]*13136)) >> 14;
out[2+n*2] = nibble[0]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
history[1] = history[0];
history[0] = out[2+n*2];
out[2+n*2+1] = (nibble[1]*(scale<<14) + (history[0]*29336) - (history[1]*13136)) >> 14;
out[2+n*2+1] = nibble[1]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
history[1] = history[0];
history[0] = out[2+n*2+1];
}