From patchwork Sat Feb 17 21:25:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7624 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp2193021jai; Sat, 17 Feb 2018 13:25:42 -0800 (PST) X-Google-Smtp-Source: AH8x226KV5dCZqakoqquTmHPwVUhjYpVfr+lIJBVtzt6uyCCvAyp1RsrygtspssnigpuJzwgSvju X-Received: by 10.28.137.137 with SMTP id l131mr1574459wmd.34.1518902742006; Sat, 17 Feb 2018 13:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518902741; cv=none; d=google.com; s=arc-20160816; b=ZbPJPCyPNH09T67sZQNlZ97UsjZhbzvGzeWoPOGP6axD3v97edm+SxfI1qkwYPnSJ+ wJl1h56c1AcBRbi/Gj5rJoh3lAMOs8TsjGhmSEPpeiOGuktphRRPdBMPU6nmtWrSbooX ibkWwfzgKDPVCKP4dux7TJ54f6ac21fkjwQNP88W2rdThedx9oAh9l/7PyZsu+oFEcUK k9MquCO8VVfqwdpre4E5XaHXLsVZcnp/+0SoGnyBZ8egGOB+rr3u+boq5DeTGSProvvv HgXYuPLd+B5HFcIQcNc6osFHoqBJ7o+B7Irfh2tvygOZ3Yszt75oGdsBnZA/BtrvrZhb oGjQ== 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=lSh0Xk+4Iq0t8rxwZc5znqOmJrdPTY1/kqSEsCsM+Zo=; b=XVHQ5jYjsh6LvVhYH18SgZKXdD2kRca0lCFk8Bohzstk+149sSLSQDpnKQ5lXEcbq7 shNFLefvCgat6Fw2eujCR0M6vYg3vwjogc21lPRXbDpapkyfM1/s5abqvdPQd00SwKSd G8Gd1vYfV2/IJWrN48pKsCQQSXeez3S5GR+810L+4TAlnmNrOfPveC3ZwUt7+Rrx/TPW 9u7rhucNKnE9vrcag5UxHpRF9BQ1GXWlTzdyAGL0Ilkfe3ZtXcghyybaMboJA5eFXkD4 Ah1D1qyqVxIHt0aK0k0Foi/r8fkqvB/r4YHUOk/9/IvlfOuc8ZVyWlSvn+pcBZnMvjmY lorA== 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 k84si2842713wmc.260.2018.02.17.13.25.41; Sat, 17 Feb 2018 13:25:41 -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 45FA96898DA; Sat, 17 Feb 2018 23:25:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08836689796 for ; Sat, 17 Feb 2018 23:25:24 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1en9z1-0007G4-S7 for ffmpeg-devel@ffmpeg.org; Sat, 17 Feb 2018 22:25:23 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id BxRD1x01Y0S5wYM01xREAF; Sat, 17 Feb 2018 22:25:14 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 17 Feb 2018 22:25:11 +0100 Message-Id: <20180217212512.18487-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180217212512.18487-1-michael@niedermayer.cc> References: <20180217212512.18487-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/hevcdec: Check luma/chroma_log2_weight_denom 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: signed integer overflow: 3 + 2147483647 cannot be represented in type 'int' Fixes: 5888/clusterfuzz-testcase-minimized-5634701067812864 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevcdec.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 8f1c1f1953..fc4eb781dc 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -151,12 +151,18 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) int luma_log2_weight_denom; luma_log2_weight_denom = get_ue_golomb_long(gb); - if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) + if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) { av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); + return AVERROR_INVALIDDATA; + } s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); if (s->ps.sps->chroma_format_idc != 0) { - int delta = get_se_golomb(gb); - s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3); + int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb); + if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) { + av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); + return AVERROR_INVALIDDATA; + } + s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom; } for (i = 0; i < s->sh.nb_refs[L0]; i++) {