[FFmpeg-devel] [PATCH 3/3] avcodec/apac: use unsigned for sample residual

Michael Niedermayer michael at niedermayer.cc
Thu Nov 17 01:32:20 EET 2022


Fixes: signed integer overflow: -2146670226 + -2227242 cannot be represented in type 'int'
Fixes: 51943/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-5779018251370496

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

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index e9f6a0dd88..72ff41bdbb 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -204,7 +204,7 @@ static int apac_decode(AVCodecContext *avctx, AVFrame *frame,
 
             for (int i = 0; i < c->block_length; i++) {
                 int val = get_bits_long(gb, c->bit_length);
-                int delta = (val & 1) ? ~(val >> 1) : (val >> 1);
+                unsigned delta = (val & 1) ? ~(val >> 1) : (val >> 1);
                 int sample;
 
                 delta += c->last_delta;
-- 
2.17.1



More information about the ffmpeg-devel mailing list