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

Submitted by Michael Niedermayer on Sept. 1, 2019, 9:10 p.m.

Details

Message ID 20190901211028.4759-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Sept. 1, 2019, 9:10 p.m.
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@niedermayer.cc>
---
 libavcodec/4xm.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

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 */