From patchwork Sun Sep 1 21:10:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14838 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 4372A448160 for ; Mon, 2 Sep 2019 00:12:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D62A687F33; Mon, 2 Sep 2019 00:12:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe08-3.mx.upcmail.net (vie01a-dmta-pe08-3.mx.upcmail.net [84.116.36.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8F51A680C13 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-pe08.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1i4X9M-0007FC-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 4X8NikiOzwlys4X8Ni3abp; 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=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=D42O7cDxSFzMHChHz90A:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Sep 2019 23:10:25 +0200 Message-Id: <20190901211028.4759-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfIGPQV/nurMUk/5H6IcCpG6XbX+SRvhiCwIP9wmM7pfdnpZE6HajcnZNHIn6jeaD06iNjOdrHwzrm3/va/kU7FwyPv3diSUgM09CkcS+7+xt+utA1dDu 03h0Qn/Eb9bdSSuHEt0psz6jtd2HCqJiLRQ1WeLcVP/rwDJ65bw2VRpb Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/vp3: Check for end of input in 2 places of vp4_unpack_macroblocks() 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: Timeout (82sec -> 1sec) Fixes: 16411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5166958151991296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/vp3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 28ed0461c7..a2bd2ef07d 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -710,6 +710,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb) has_partial = 0; bit = get_bits1(gb); for (i = 0; i < s->yuv_macroblock_count; i += current_run) { + if (get_bits_left(gb) <= 0) + return AVERROR_INVALIDDATA; current_run = vp4_get_mb_count(s, gb); if (current_run > s->yuv_macroblock_count - i) return -1; @@ -719,6 +721,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb) } if (has_partial) { + if (get_bits_left(gb) <= 0) + return AVERROR_INVALIDDATA; bit = get_bits1(gb); current_run = vp4_get_mb_count(s, gb); for (i = 0; i < s->yuv_macroblock_count; i++) {