From patchwork Sun Sep 1 21:10:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14837 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 38CC1448160 for ; Mon, 2 Sep 2019 00:12:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C9CC687F09; Mon, 2 Sep 2019 00:12:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91A9D687F2D for ; Mon, 2 Sep 2019 00:12:40 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1i4X9M-000AEn-37 for ffmpeg-devel@ffmpeg.org; Sun, 01 Sep 2019 23:12:40 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 4X8OikiQ3wlys4X8Oi3abw; Sun, 01 Sep 2019 23:11:40 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=lslgFxn7sPNIki8UiJIA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=SsAZrZ5W_gNWK9tOzrEV:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Sep 2019 23:10:26 +0200 Message-Id: <20190901211028.4759-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190901211028.4759-1-michael@niedermayer.cc> References: <20190901211028.4759-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfIGPQV/nurMUk/5H6IcCpG6XbX+SRvhiCwIP9wmM7pfdnpZE6HajcnZNHIn6jeaD06iNjOdrHwzrm3/va/kU7FwyPv3diSUgM09CkcS+7+xt+utA1dDu 03h0Qn/Eb9bdSSuHEt0psz6jtd2HCqJiLRQ1WeLcVP/rwDJ65bw2VRpb Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/4xm: Check for end of input in decode_i_block() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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 */