ffmpeg | branch: release/6.0 | Michael Niedermayer <mich...@niedermayer.cc> | 
Mon Feb 20 19:53:19 2023 +0100| [0c1e67ab140c52c03b12cfb10f78064921504eb9] | 
committer: Michael Niedermayer

avcodec/rka: Fix some integer anomalies

Fixes: left shift of negative value -3201
Fixes: integer overflow: -76470276 * -25608 cannot be represented in type 'int'
Fixes: 
56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit d495747a9fc5fb8dcac4b23c5bdca3c5c16dd152)
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

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

 libavcodec/rka.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/rka.c b/libavcodec/rka.c
index 461baf1e1f..994c563ffd 100644
--- a/libavcodec/rka.c
+++ b/libavcodec/rka.c
@@ -723,16 +723,16 @@ static int decode_filter(RKAContext *s, ChContext *ctx, 
ACoder *ac, int off, uns
             last_val = val;
             src = &ctx->buf1[off + -1];
             for (int i = 0; i < filt.size && i < 15; i++)
-                sum += filt.coeffs[i] * src[-i];
+                sum += filt.coeffs[i] * (unsigned)src[-i];
             sum = sum * 2;
             for (int i = 15; i < filt.size; i++)
-                sum += filt.coeffs[i] * src[-i];
+                sum += filt.coeffs[i] * (unsigned)src[-i];
             sum = sum >> 6;
             if (ctx->cmode == 0) {
                 if (bits == 0) {
                     ctx->buf1[off] = sum + val;
                 } else {
-                    ctx->buf1[off] = (val + (sum >> bits) << bits) +
+                    ctx->buf1[off] = (val + (sum >> bits)) * (1 << bits) +
                         (((1U << bits) - 1U) & ctx->buf1[off + -1]);
                 }
                 ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1];

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to