diff mbox series

[FFmpeg-devel,3/5] avcodec/rka: Avoid undefined left shift

Message ID 20230525214019.29048-3-michael@niedermayer.cc
State Accepted
Commit 1ee303f1e1677fd997da05ae1cc6aca064f96bdb
Headers show
Series [FFmpeg-devel,1/5] avformat/mov: We do not support creation times of 300 billion years ago | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 25, 2023, 9:40 p.m. UTC
Fixes: left shift of 34136248 by 6 places cannot be represented in type 'int'
Fixes: 58429/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5692211592560640

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

Patch

diff --git a/libavcodec/rka.c b/libavcodec/rka.c
index 3e86d83819..01920dbba5 100644
--- a/libavcodec/rka.c
+++ b/libavcodec/rka.c
@@ -750,7 +750,7 @@  static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
         }
         if (ctx->cmode2 != 0) {
             int sum = 0;
-            for (int i = (m << 6) / split; i > 0; i = i >> 1)
+            for (int i = (signed)((unsigned)m << 6) / split; i > 0; i = i >> 1)
                 sum++;
             sum = sum - (ctx->cmode2 + 7);
             ctx->cmode = FFMAX(sum, tab[ctx->cmode2]);