Commit aaeec1c6 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/wavpack: Fix signed integer overflow: 1285114081 * 2 cannot be represented in type 'int'

Fixes: 945/clusterfuzz-testcase-6037937588273152
Fixes: integer overflow

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 2cb656ad
...@@ -240,7 +240,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, ...@@ -240,7 +240,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
if (get_bits_left(gb) <= 0) if (get_bits_left(gb) <= 0)
goto error; goto error;
} else { } else {
int mid = (base * 2 + add + 1) >> 1; int mid = (base * 2U + add + 1) >> 1;
while (add > c->error_limit) { while (add > c->error_limit) {
if (get_bits_left(gb) <= 0) if (get_bits_left(gb) <= 0)
goto error; goto error;
...@@ -249,7 +249,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, ...@@ -249,7 +249,7 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb,
base = mid; base = mid;
} else } else
add = mid - base - 1; add = mid - base - 1;
mid = (base * 2 + add + 1) >> 1; mid = (base * 2U + add + 1) >> 1;
} }
ret = mid; ret = mid;
} }
......
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