avcodec/ralf: fix undefined shift
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 17 Aug 2019 17:18:31 +0000 (19:18 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 2 Sep 2019 19:37:18 +0000 (21:37 +0200)
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

index 619fd71..d2d803b 100644 (file)
@@ -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);