From patchwork Wed Aug 16 14:03:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4722 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp812374vsu; Wed, 16 Aug 2017 07:17:30 -0700 (PDT) X-Received: by 10.28.127.135 with SMTP id a129mr1441822wmd.91.1502893050026; Wed, 16 Aug 2017 07:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502893049; cv=none; d=google.com; s=arc-20160816; b=BSHfmgPjSYVjYeAlyDRRBcM5ksrGjVf3XZHJn8rQIOAVSDQBewNCQ/+rYj3P+/cr5S l0cevIeaVxCwN5kh4pAvfhL/IxzAobol79vZybJfP2GWVqfQZG4GQk2qpvsNbjslB53f jGcTC30PpWYg5MIW46nRzbDF96c86eQSCRhH0eXLTMBZfYcwkTg1ySgAsbjMkrUX2OzQ YmIXCD4BeHx/yC+07xsnjG7TtOsmsl5CrZSyP1Xp8KAYxkjmCYHqlmrqXOutui5h3wu1 72O9ZtMzH1pA1RqDX31UdLs4kQ3pEZ2jmtW2AyPcFDzM5iEp0WVFlxKNWegmK8IGsNsV Oc0Q== 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=2utioTs/rN3hF2RuB6au+Ykt/hYS7JSD0i9h4UIvDjA=; b=h/BkR6jI7AYWNdtgu0TTxfN87uQdqWS4ioSOlJN+jxDg7JpIsSGSvLGdLdLB156rHA FrWgKfveNk+lcH731dYQ8f3CQzuFZrQVsLTYjnvYfIDLeQKdq4/Nq5tqCtoRRZLTwMaR UrTFJMxGqV/ic7irLzTwU4Snqu6VU7IuDmR9ENlN49FTdrJAZJ5uWGIXkX/r1h1CERnj gvPxL/WkDj7HUBcBKeqLsP36DB5205szli+Wru2ceDH4WmpE9N1I6iBJTVesYvl+fkKb Bx2Mh/CeYSa+jh7BJ9ENAUCYZtDeXQqxCcEBnHcF4notqhasB/5yMeunTcjSgSj/x3JU W4HA== 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 h23si765415wrc.188.2017.08.16.07.17.29; Wed, 16 Aug 2017 07:17:29 -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 699D868995D; Wed, 16 Aug 2017 17:17:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-2.mx.upcmail.net (vie01a-qmta-pe01-2.mx.upcmail.net [62.179.121.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7508C689821 for ; Wed, 16 Aug 2017 17:17:14 +0300 (EEST) Received: from [172.31.218.43] (helo=vie01a-dmta-pe05-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dhz8I-0007UZ-SF for ffmpeg-devel@ffmpeg.org; Wed, 16 Aug 2017 16:17:18 +0200 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 1dhz8D-0006Vm-1q for ffmpeg-devel@ffmpeg.org; Wed, 16 Aug 2017 16:17:13 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id xq3P1v01U0S5wYM01q3QQ2; Wed, 16 Aug 2017 16:03:24 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 16 Aug 2017 16:03:23 +0200 Message-Id: <20170816140323.14785-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index f126515bd1..b09dc41ebd 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -589,6 +589,11 @@ static av_cold int decode_init(AVCodecContext *avctx) // Needed if zlib unused or init aborted before inflateInit memset(&c->zstream, 0, sizeof(z_stream)); + if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) { + av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n"); + return AVERROR_INVALIDDATA; + } + c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64); /* Allocate decompression buffer */