[FFmpeg-devel,1/6] avcodec/ralf: fix undefined shift

Submitted by Michael Niedermayer on Aug. 17, 2019, 11:28 p.m.

Details

Message ID 20190817232841.14709-1-michael@niedermayer.cc
State Accepted
Commit 0ee886988e75b3c22cabc2ca0fadcf8e4f787640
Headers show

Commit Message

Michael Niedermayer Aug. 17, 2019, 11:28 p.m.
Fixes: left shift of negative value -2
Fixes: 16145/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5146671058518016

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Sept. 2, 2019, 6:16 p.m.
On Sun, Aug 18, 2019 at 01:28:36AM +0200, Michael Niedermayer wrote:
> Fixes: left shift of negative value -2
> Fixes: 16145/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5146671058518016
> 
> 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index 619fd7126a..d2d803b0d4 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -300,8 +300,8 @@  static int decode_channel(RALFContext *ctx, GetBitContext *gb, int ch,
         t = get_vlc2(gb, code_vlc->table, code_vlc->bits, 2);
         code1 = t / range2;
         code2 = t % range2;
-        dst[i]     = extend_code(gb, code1, range, 0) << add_bits;
-        dst[i + 1] = extend_code(gb, code2, range, 0) << add_bits;
+        dst[i]     = extend_code(gb, code1, range, 0) * (1 << add_bits);
+        dst[i + 1] = extend_code(gb, code2, range, 0) * (1 << add_bits);
         if (add_bits) {
             dst[i]     |= get_bits(gb, add_bits);
             dst[i + 1] |= get_bits(gb, add_bits);