[FFmpeg-devel] [PATCH 2/4] avcodec/4xm: Check for end of input in decode_i_block()

Michael Niedermayer michael at niedermayer.cc
Mon Sep 2 00:10:26 EEST 2019


Fixes: signed integer overflow: 2147483644 + 16 cannot be represented in type 'int'
Fixes: 16782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5743163859271680

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/4xm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 1f4e2aee24..f0f279b5c6 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -518,6 +518,9 @@ static int decode_i_block(FourXContext *f, int16_t *block)
     /* AC coefs */
     i = 1;
     for (;;) {
+        if (get_bits_left(&f->pre_gb) <= 0)
+            return AVERROR_INVALIDDATA;
+
         code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);
 
         /* EOB */
-- 
2.23.0



More information about the ffmpeg-devel mailing list