From patchwork Wed Feb 19 15:49:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 17850 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 576C944A5E5 for ; Wed, 19 Feb 2020 17:51:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 21CC668AEA7; Wed, 19 Feb 2020 17:51:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-2.mx.upcmail.net (vie01a-dmta-pe03-2.mx.upcmail.net [62.179.121.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A3ED068AEA7 for ; Wed, 19 Feb 2020 17:50:54 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1j4Rck-0006qu-0V for ffmpeg-devel@ffmpeg.org; Wed, 19 Feb 2020 16:50:54 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 4RbjjmrUUwlys4RbjjUbhm; Wed, 19 Feb 2020 16:49:53 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=sfOm8-O8AAAA:8 a=e6oDp01gZae1hGwZHLIA:9 a=TvTJqdcANYtsRzA46cdi:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 19 Feb 2020 16:49:51 +0100 Message-Id: <20200219154951.30466-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfCuB43bf6q5AMOTJgdak23KzNBnh66SXuOBEE8I9G2eUsULzZnqHTb3iSoogiVNOZaAsxO4ZUVI9+s3qtQoXDpoLQVwgYHFPOLn+1d4U1RbabwYJ4pYk Ta1unJhaW90hSURNGPDyOCHwY3SyI33qSoa5iPkCEIJ8uZCPWqBjtsXo Subject: [FFmpeg-devel] [PATCH] avcodec/tiff: Check for Tiled and Stripped TIFFs 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" TIFF 6 spec: "Do not use both strip-oriented and tile-oriented fields in the same TIFF file." Fixes: null pointer use, crash Fixes: crash-762680f9d1b27f9b9085e12887ad44893fb2b020 Found-by: Shiziru Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index e8357114de..fd50b1cbfa 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1873,6 +1873,12 @@ again: return AVERROR_INVALIDDATA; } + if ( (s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length || s->tile_count) + && (s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff)) { + av_log(avctx, AV_LOG_ERROR, "Tiled TIFF is not allowed to strip\n"); + return AVERROR_INVALIDDATA; + } + /* now we have the data and may start decoding */ if ((ret = init_image(s, &frame)) < 0) return ret;