From patchwork Tue Feb 27 15:53:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7757 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp2705214jaj; Tue, 27 Feb 2018 07:53:48 -0800 (PST) X-Google-Smtp-Source: AH8x225x+0UQH3GdcFt+dgMyc6MSd6rQj/gkd5BA5vQEJDTOnFCAyL8dx7m06ec5qMPbjCeWJW6o X-Received: by 10.223.169.4 with SMTP id u4mr12036427wrc.170.1519746828117; Tue, 27 Feb 2018 07:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519746828; cv=none; d=google.com; s=arc-20160816; b=sLDCQROHbnfR0p6kSXDjuweUVby7eWdLIC5Pr8fFMpkL7stnfOkwaijw/+yoBVo+fr ocGPfHKmcNCy2BBxbQbTlxZo8en3mEMcTJsWvISPpoHVL1ZQZGOyGY9rmiXGrPxzc2JC nCFFC/RgffV2338LWTv8Ti/uyw7kd8OR63317AAL1f28bze/hy26ZLjNJHwYBZBszVr7 WqQqm7JDmaHL1A+8ufYwXm0EYqTLeytZa0iFO4ic88Kh+swwdclqi6vwVTBLKGezOhwt cV5xOdqIjnleAaSTUA5OgE2ZTHgHdH3KpYqarQpEM4xMMSe+gVPQbXi3wq1Ew5lmEyjv iy8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=4MKuvAWrUBtOgGf6CEI+wKGCZmYbmO3jdMyHFBLlS/A=; b=PIHZETsGkZ3AiceWdNPsro3uvM0d+Aq/dPrfIYEqz/aKS5nj67gMy1xyVRuBo0Y0bm h1ruI9zywlhGQ6Ge3xwNjMkz0N+EqYYzM3gbN/hnBlJDK/+Hi2MA4u4bz1EvmO+ePGDV AXiFJcAPHqzD4PtvpiOKpjXnWpprexKdD0O+lUMdavOVsreErdPe4JsaWpmqF2ch2ves Bo5UL9zljPbbX8duwjBxpCoPi/x4KrfBQ7g8LE/eq50iF0g3seoFr0iULrMA0OnjLQZk oZzeMWhWsOjfeoP3WPNmjvNbaYt2xc6DOo2qWCPZK1N8MIzwOfnfr35Bv/2WlziDLCQx i01g== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 45si3368801wrz.435.2018.02.27.07.53.47; Tue, 27 Feb 2018 07:53:48 -0800 (PST) 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 E686968A3E8; Tue, 27 Feb 2018 17:53:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-1.mx.upcmail.net (vie01a-qmta-pe01-1.mx.upcmail.net [62.179.121.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FDBF68A3DE for ; Tue, 27 Feb 2018 17:53:35 +0200 (EET) Received: from [172.31.218.44] (helo=vie01a-dmta-pe05-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eqhZT-0001o6-98 for ffmpeg-devel@ffmpeg.org; Tue, 27 Feb 2018 16:53:39 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eqhZN-00076o-FI for ffmpeg-devel@ffmpeg.org; Tue, 27 Feb 2018 16:53:33 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id FrtS1x00q0S5wYM01rtTAd; Tue, 27 Feb 2018 16:53:27 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 27 Feb 2018 16:53:24 +0100 Message-Id: <20180227155324.3220-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227155324.3220-1-michael@niedermayer.cc> References: <20180227155324.3220-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/nuv: Check for minimum input size for uncomprssed and rtjpeg 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: Timeout Fixes: 6297/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-4882404863901696 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/nuv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 15165ae3f5..32ed65899b 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -161,6 +161,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, int orig_size = buf_size; int keyframe, ret; int size_change = 0; + int minsize = 0; int result, init_frame = !avctx->frame_number; enum { NUV_UNCOMPRESSED = '0', @@ -209,6 +210,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, keyframe = 1; break; } + switch (comptype) { + case NUV_UNCOMPRESSED: + minsize = c->width * c->height * 3 / 2; + break; + case NUV_RTJPEG: + minsize = c->width/16 * (c->height/16) * 6; + break; + } + if (buf_size < minsize / 4) + return AVERROR_INVALIDDATA; retry: // Skip the rest of the frame header. buf = &buf[12];