From patchwork Wed Aug 16 03:04:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4717 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.46.75.1 with SMTP id y1csp317676lja; Tue, 15 Aug 2017 20:04:58 -0700 (PDT) X-Received: by 10.223.164.154 with SMTP id g26mr119019wrb.230.1502852698053; Tue, 15 Aug 2017 20:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502852698; cv=none; d=google.com; s=arc-20160816; b=F5HE3I/0uxu0ZMMdY45t4qxMHQf71IdTfFP0SWFlatwlyK+SBMOjrKrDuxAyNzBxkx zse0UiRPT1zagIv43LEChJdbF+uRTBGsNHaOdAtAb9fw2fdx6VpjikS6QqEvU7mhtFFw RFeUhMIye+gMaOwKDoPrpwl5fx9QL6dIb8QiiSZ9jx/mPiJ6UG3Cwr0bNRpdb1ilEcZe m3o8ET4L36VJwa09fdLP4CSHG/54Pl2mb06QsUv+cmR/KtwXxb/Ay5lkeSiBW1aRYhcg VeR8tL03Jz/8FLZ/iDjMBqHiMx3Y5k6XUxaMSYIxkLqomSMMij9aFzPcJqoyaax9uytg qNIg== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=dLch37BXa8QWBR/w6PoxBs74UD8KjwuMLMhVetBxlbs=; b=dY6qp7xdte0s1iUeGD+q6hzxw1JKiYIdNw16IwMCR2NDO7uyOqbKlqq2eFZikeWC4s 12PgrAT1cCbIEEyJ8LRQT24MzSGO4oPQ1Rs6VzV2dqMuvu5ilcOHKYwQtY++Hi/GmTZ3 6XgzHTrAIvDfZ/C6FKmvH5qanXl87OgTKxZ0E7Qxa6m4hXYZe8TJCP2O/WYj/iA+hjWa GiOUleodOmD4r1eUiiW5al+vpB2EzDDwHAtSg1AJcDKau0PbTzavKJVKmfabw8yR/2fO FO27ceEiOrrSjIRWx8A4ZEVKzI1N0usjfXCgBF7VTfiosfoIHz4LGeoJSMFzQD3DxQ4z dQvA== 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 j9si8121009wrc.424.2017.08.15.20.04.57; Tue, 15 Aug 2017 20:04:58 -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 331BF6882F9; Wed, 16 Aug 2017 06:04:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-2.mx.upcmail.net (vie01a-dmta-pe04-2.mx.upcmail.net [62.179.121.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 628216882A7 for ; Wed, 16 Aug 2017 06:04:44 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dhodU-0000Ud-Ek for ffmpeg-devel@ffmpeg.org; Wed, 16 Aug 2017 05:04:48 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id xf4j1v00G0S5wYM01f4k5Y; Wed, 16 Aug 2017 05:04:44 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 16 Aug 2017 05:04:42 +0200 Message-Id: <20170816030442.31512-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 Subject: [FFmpeg-devel] [PATCH] avcodec/zmbv: Check decomp_size 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: OOM Fixes: 2710/clusterfuzz-testcase-minimized-4750001420894208 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/zmbv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index f126515bd1..861098a0f2 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -589,8 +589,12 @@ static av_cold int decode_init(AVCodecContext *avctx) // Needed if zlib unused or init aborted before inflateInit memset(&c->zstream, 0, sizeof(z_stream)); - c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64); + if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > avctx->max_pixels) { + av_log(avctx, AV_LOG_ERROR, "Internal buffer larger than max_pixels\n"); + return AVERROR_INVALIDDATA; + } + c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64); /* Allocate decompression buffer */ if (c->decomp_size) { if (!(c->decomp_buf = av_mallocz(c->decomp_size))) {