[FFmpeg-devel,2/4] avcodec/sonic: Fix integer overflow in predictor_calc_error()

Submitted by Michael Niedermayer on Oct. 22, 2019, 2:27 p.m.

Details

Message ID 20191022142704.8818-2-michael@niedermayer.cc
State Accepted
Commit c8c17b8cef77dc052e8845e5fd86daf2983fd7dd
Headers show

Commit Message

Michael Niedermayer Oct. 22, 2019, 2:27 p.m.
Fixes: signed integer overflow: 5 * -1094995529 cannot be represented in type 'int'
Fixes: 18346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5709623893426176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/sonic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 20, 2019, 2:06 p.m.
On Tue, Oct 22, 2019 at 04:27:02PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 5 * -1094995529 cannot be represented in type 'int'
> Fixes: 18346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5709623893426176
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/sonic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index b890d79c28..c975774b04 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -475,7 +475,7 @@  static int predictor_calc_error(int *k, int *state, int order, int error)
     {
         int k_value = *k_ptr, state_value = *state_ptr;
         x -= shift_down(k_value * state_value, LATTICE_SHIFT);
-        state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
+        state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT);
     }
 #else
     for (i = order-2; i >= 0; i--)