summaryrefslogtreecommitdiff
path: root/libavcodec/sonic.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-05-10 21:09:45 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-06-14 19:17:07 +0200
commit61d9bf514de0acf256aa554e0c431e7c91e42a5c (patch)
treea9ec8d398de56a4b1efc3456744e18917b56c7b7 /libavcodec/sonic.c
parent75d520e33704447f1b29ac47fd9e40994a6bc659 (diff)
avcodec/sonic: Fix several integer state overflows
Fixes: signed integer overflow: -234 * -14797801 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 Fixes: 22275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/sonic.c')
-rw-r--r--libavcodec/sonic.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index b82c44344c..ea6ef10c9e 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -458,8 +458,8 @@ static void predictor_init_state(int *k, int *state, int order)
for (j = 0, p = i+1; p < order; j++,p++)
{
- int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT);
- state[p] += shift_down(k[j]*x, LATTICE_SHIFT);
+ int tmp = x + shift_down(k[j] * (unsigned)state[p], LATTICE_SHIFT);
+ state[p] += shift_down(k[j]* (unsigned)x, LATTICE_SHIFT);
x = tmp;
}
}
@@ -467,7 +467,7 @@ static void predictor_init_state(int *k, int *state, int order)
static int predictor_calc_error(int *k, int *state, int order, int error)
{
- int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT);
+ int i, x = error - shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT);
#if 1
int *k_ptr = &(k[order-2]),