From patchwork Mon Feb 18 00:07:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 12097 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 768B8448A56 for ; Mon, 18 Feb 2019 02:09:28 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 59CA968AA8E; Mon, 18 Feb 2019 02:09:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-1.mx.upcmail.net (vie01a-dmta-pe07-1.mx.upcmail.net [84.116.36.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C44C68AA74 for ; Mon, 18 Feb 2019 02:09:22 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gvWUr-0003n0-0H for ffmpeg-devel@ffmpeg.org; Mon, 18 Feb 2019 01:09:21 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id vWTtgOS4j2WSsvWTtgGat8; Mon, 18 Feb 2019 01:08:21 +0100 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=E7kcWpVl 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=noHEtNrN1ZvYnCRu26kA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 18 Feb 2019 01:07:56 +0100 Message-Id: <20190218000756.29768-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218000756.29768-1-michael@niedermayer.cc> References: <20190218000756.29768-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfJMDHD9lHSykJeLTQZZFQ6OR6DwqWfX0LQO1oQf/9jx9cILmGOJmsQrjdneeogS7HpWXutV2Wq35qjmLl40n+fk2dxkBcLqq0plPDfKeoyvNaoNvSjN5 Mqfa/ppi951j0ygsTxVtnh9fmw+tr65Vp5BZrMk2wPHJtIyyZ4t/K8JF Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/arbc: Check nb_tiles against dimensions 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 Fixes: 12967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5639021454163968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/arbc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c index 4558304f12..841a9f10ac 100644 --- a/libavcodec/arbc.c +++ b/libavcodec/arbc.c @@ -45,6 +45,9 @@ static void fill_tile4(AVCodecContext *avctx, uint8_t *color, AVFrame *frame) int nb_tiles = bytestream2_get_le16(gb); int h = avctx->height - 1; + if ((avctx->width / 4 + 1) * (avctx->height / 4 + 1) < nb_tiles) + return; + for (int i = 0; i < nb_tiles; i++) { int y = bytestream2_get_byte(gb); int x = bytestream2_get_byte(gb); @@ -79,6 +82,9 @@ static void fill_tileX(AVCodecContext *avctx, int tile_width, int tile_height, int nb_tiles = bytestream2_get_le16(gb); int h = avctx->height - 1; + if ((avctx->width / tile_width + 1) * (avctx->height / tile_height + 1) < nb_tiles) + return; + for (int i = 0; i < nb_tiles; i++) { int y = bytestream2_get_byte(gb); int x = bytestream2_get_byte(gb);