From patchwork Sun Mar 31 15:31:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 12542 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 477FB448CE8 for ; Sun, 31 Mar 2019 18:33:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E0C568AA54; Sun, 31 Mar 2019 18:33:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-3.mx.upcmail.net (vie01a-dmta-pe06-3.mx.upcmail.net [84.116.36.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F8BD689CC9 for ; Sun, 31 Mar 2019 18:33:34 +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.91) (envelope-from ) id 1hAcSj-000Abu-1d for ffmpeg-devel@ffmpeg.org; Sun, 31 Mar 2019 17:33:33 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id AcRlhvnrkxLwqAcRlhZsZK; Sun, 31 Mar 2019 17:32:33 +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=WaxylHpX 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=YXaX6gwqYwgrErwWGs4A:9 a=vyu8cVnh4x_3Rv8q:21 a=U7yFtjAqi620rSVU:21 a=1fhp2MxaeJtTNGEnv6mo:22 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 31 Mar 2019 17:31:17 +0200 Message-Id: <20190331153117.19239-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfOzcJMgqysZVBQxMXspL9/8mHhuyJERrRvNIwVhhp++CMFd3o5Jiok5nRnqcva2bNwyNkyF6R/aEvstxAROT8FiPu+lPVpObJ02lOtV6p0QDo2N8EX3r eAttZ2QyiESNNQUxXFkH7XMZJhhRsOdZViAN9d6Hik8mSYuA/UB38wON Subject: [FFmpeg-devel] [PATCH] avcodec/rscc: Check that the to be uncompressed input is large enough 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: Out of array access Fixes: 13984/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-5734128093233152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/rscc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c index 7d4e842cd3..4adee9d7d4 100644 --- a/libavcodec/rscc.c +++ b/libavcodec/rscc.c @@ -199,6 +199,13 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data, /* If necessary, uncompress tiles, and hijack the bytestream reader */ if (packed_tiles_size != tiles_nb * TILE_SIZE) { uLongf length = tiles_nb * TILE_SIZE; + + if (bytestream2_get_bytes_left(gbc) < packed_tiles_size) { + av_log(avctx, AV_LOG_ERROR, "compressed input truncated\n"); + ret = AVERROR_INVALIDDATA; + goto end; + } + inflated_tiles = av_malloc(length); if (!inflated_tiles) { ret = AVERROR(ENOMEM);