diff mbox

[FFmpeg-devel,4/4] avcodec/apedec: Fix undefined integer overflow in decode_array_0000()

Message ID 20191207232012.29634-4-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Dec. 7, 2019, 11:20 p.m. UTC
Fixes: signed integer overflow: -2143289344 - 6246400 cannot be represented in type 'int'
Fixes: 19239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5173755680915456

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

Patch

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 2b5bd759f5..ebda288043 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -614,7 +614,7 @@  static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
             return ;
         }
         out[i] = get_rice_ook(&ctx->gb, rice->k);
-        rice->ksum += out[i] - out[i - 64];
+        rice->ksum += out[i] - (unsigned)out[i - 64];
         while (rice->ksum < ksummin) {
             rice->k--;
             ksummin = rice->k ? ksummin >> 1 : 0;