diff mbox

[FFmpeg-devel,5/5] avcodec/ralf: use multiply instead of shift to avoid undefined behavior in decode_block()

Message ID 20191102160601.14711-5-michael@niedermayer.cc
State Accepted
Commit 1b7d02642b2096622cee6165fea1301bb9ad54ff
Headers show

Commit Message

Michael Niedermayer Nov. 2, 2019, 4:06 p.m. UTC
Fixes: left shift of negative value -249
Fixes: 18566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5649394561187840

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 20, 2019, 2:10 p.m. UTC | #1
On Sat, Nov 02, 2019 at 05:06:01PM +0100, Michael Niedermayer wrote:
> Fixes: left shift of negative value -249
> Fixes: 18566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5649394561187840
> 
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 1d881cf7ae..ca8817aa21 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -408,7 +408,7 @@  static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
     case 4:
         for (i = 0; i < len; i++) {
             t  =   ch1[i] + ctx->bias[1];
-            t2 = ((ch0[i] + ctx->bias[0]) << 1) | (t & 1);
+            t2 = ((ch0[i] + ctx->bias[0]) * 2) | (t & 1);
             dst0[i] = (t2 + t) / 2;
             dst1[i] = (t2 - t) / 2;
         }