diff mbox series

[FFmpeg-devel,3/3] avcodec/fastaudio: Fix invalid shift exponent

Message ID 20200908212921.7408-4-michael@niedermayer.cc
State New
Headers show
Series avcodec/fastaudio: Bugfixes
Related show

Checks

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

Commit Message

Michael Niedermayer Sept. 8, 2020, 9:29 p.m. UTC
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 25434/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-6252363168612352

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

Patch

diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c
index 16f44790f5..e37d4f8425 100644
--- a/libavcodec/fastaudio.c
+++ b/libavcodec/fastaudio.c
@@ -92,7 +92,7 @@  static int read_bits(int bits, int *ppos, unsigned *src)
 
     pos = *ppos;
     pos += bits;
-    r = src[(pos - 1) / 32] >> (32 - pos % 32);
+    r = src[(pos - 1) / 32] >> ((-pos) & 31);
     *ppos = pos;
 
     return r & ((1 << bits) - 1);