From patchwork Tue Mar 14 00:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2921 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1389642vsy; Mon, 13 Mar 2017 17:52:52 -0700 (PDT) X-Received: by 10.223.144.65 with SMTP id h59mr34445305wrh.30.1489452772857; Mon, 13 Mar 2017 17:52:52 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v16si2783163wrv.32.2017.03.13.17.52.52; Mon, 13 Mar 2017 17:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B776680AF7; Tue, 14 Mar 2017 02:52:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F398680872 for ; Tue, 14 Mar 2017 02:52:19 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1cnahW-0002Np-Eo for ffmpeg-devel@ffmpeg.org; Tue, 14 Mar 2017 01:52:34 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id vcsS1u00c0S5wYM01csToH; Tue, 14 Mar 2017 01:52:27 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 14 Mar 2017 01:52:24 +0100 Message-Id: <20170314005224.24980-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170314005224.24980-1-michael@niedermayer.cc> References: <20170314005224.24980-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/tiff: Check palette shift 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes multiple runtime error: shift exponent 792 is too large for 32-bit type 'unsigned int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 456da5142b..0be7be7528 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -996,6 +996,11 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) bytestream2_skip(&pal_gb[2], count / 3 * off * 2); off = (type_sizes[type] - 1) << 3; + if (off > 31U) { + av_log(s->avctx, AV_LOG_ERROR, "palette shift %d is out of range\n", off); + return AVERROR_INVALIDDATA; + } + for (i = 0; i < count / 3; i++) { uint32_t p = 0xFF000000; p |= (ff_tget(&pal_gb[0], type, s->le) >> off) << 16;