diff mbox series

[FFmpeg-devel,3/7] avcodec/ralf: Fix integer overflow in decode_block()

Message ID 20200510192019.14218-3-michael@niedermayer.cc
State Accepted
Commit 0c4330847c104fcf3ef929c1acee33b5b34c20db
Headers show
Series [FFmpeg-devel,1/7] avcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate fail Make fate failed

Commit Message

Michael Niedermayer May 10, 2020, 7:20 p.m. UTC
Fixes: signed integer overflow: 289082077 - -2003141111 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5196077752123392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ralf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer May 11, 2020, 10:58 p.m. UTC | #1
On Sun, May 10, 2020 at 09:20:15PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 289082077 - -2003141111 cannot be represented in type 'int'
> Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5196077752123392
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ralf.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 831728177e..08e8043e30 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -344,7 +344,8 @@  static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
     int len, ch, ret;
     int dmode, mode[2], bits[2];
     int *ch0, *ch1;
-    int i, t, t2;
+    int i;
+    unsigned int t, t2;
 
     len = 12 - get_unary(gb, 0, 6);
 
@@ -409,8 +410,8 @@  static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
         for (i = 0; i < len; i++) {
             t  =   ch1[i] + ctx->bias[1];
             t2 = ((ch0[i] + ctx->bias[0]) * 2) | (t & 1);
-            dst0[i] = (t2 + t) / 2;
-            dst1[i] = (t2 - t) / 2;
+            dst0[i] = (int)(t2 + t) / 2;
+            dst1[i] = (int)(t2 - t) / 2;
         }
         break;
     }