Commit 58e9c7f4 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/wavpack: Fix multiple integer overflows

Fixes: 839/clusterfuzz-testcase-4871084446842880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 45198477
......@@ -268,7 +268,7 @@ error:
}
static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc,
int S)
unsigned S)
{
unsigned bit;
......@@ -415,11 +415,11 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
if (t > 0) {
if (t > 8) {
if (t & 1) {
A = 2 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
B = 2 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1];
A = 2U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
B = 2U * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1];
} else {
A = (3 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
B = (3 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1;
A = (int)(3U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
B = (int)(3U * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1;
}
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
s->decorr[i].samplesB[1] = s->decorr[i].samplesB[0];
......@@ -488,7 +488,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
pos = (pos + 1) & 7;
if (s->joint)
L += (R -= (L >> 1));
L += (unsigned)(R -= (unsigned)(L >> 1));
crc = (crc * 3 + L) * 3 + R;
if (type == AV_SAMPLE_FMT_FLTP) {
......
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