[FFmpeg-cvslog] avcodec/wavpack: Fix overflow in p=31

Michael Niedermayer git at videolan.org
Sun Dec 4 22:59:24 EET 2022


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Sep 11 12:00:31 2022 +0200| [9bfae838563b9cf7ced9053265cfdb4405bce7eb] | committer: Michael Niedermayer

avcodec/wavpack: Fix overflow in p=31

Untested with "non fuzzed" samples as i have no such file
The reference 5.6.0 decoder appears to also have undefined behavior in the lossless codepath for this

Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 50930/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-6319201949712384

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9bfae838563b9cf7ced9053265cfdb4405bce7eb
---

 libavcodec/wavpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index ea77ae7749..3cb4077550 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -126,7 +126,7 @@ static av_always_inline unsigned get_tail(GetBitContext *gb, unsigned k)
     if (k < 1)
         return 0;
     p   = av_log2(k);
-    e   = (1 << (p + 1)) - k - 1;
+    e   = (1LL << (p + 1)) - k - 1;
     res = get_bits_long(gb, p);
     if (res >= e)
         res = (res << 1) - e + get_bits1(gb);



More information about the ffmpeg-cvslog mailing list