From patchwork Mon Jan 15 23:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7295 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp3497825jaa; Mon, 15 Jan 2018 15:37:47 -0800 (PST) X-Google-Smtp-Source: ACJfBotix7Esg8ijeSd3HzliYt5QDX38Rg10eiy17tYZ7TQjURLhvoTMvjBtHR8ibeDEhpRGbQsO X-Received: by 10.223.188.77 with SMTP id a13mr12144614wrh.161.1516059467662; Mon, 15 Jan 2018 15:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516059467; cv=none; d=google.com; s=arc-20160816; b=jjeoSHX1V7cLWXo+7o5LYnpl8opBOWh17e6cVhrCHBf8KHccJBXhHl+mpQbuig85et bH7w+vBJzvpCGvOJey+RM1U80Il2jONEXQoreB5U9bGvrtD5UGbN023ZqCQ0QqHupemT 52nQhAb9xyPuTTR40/oZa5a7O9hzX4CNuNbHm9RPVR4M5QDdKPZmcgwvxy9v3QNI7LPq z7ls+Q0EV7Rpju8hlPOkO13waaV+DWFydrBb2fYAqaJz/yRUIhg1Sq7UpQZzilkj5KIh F5l7Db3CCkJj2e/MEFUjS3Y3jBmYTSECJcL4VQgwLsJoCxKTrvYzP0NNVAqcM5DRBtdC +VzA== 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=/soVDue7fIw08RZQDNT5avEcPleqArmJQxdp0cBRP88=; b=M2kTho1PgsJDk1ccK+gfk2xZN7DQGAPAjuBsetItIgh5LWp+anSsMQODDssLwsw/qG 9LCgRHT5FmvHZ0JrAmLeG1WklJSd5Aq10X2lQkBK6Fl9AJYBnUVBllbPPHIAyY3HVvED 3BOh5sAsZdzMsadBMYIt/sUJi2E9ymUkAF46uXKkyEdR0MV1BqQzUM/pP44ykiLoJbb2 Xr/0s83WrGSVibwTDFhzeDwSmI+mw4sZM9VFLuh4+awZcLsQ7QHq+P/QccjhnoAk/H1I G/F30nox2GTchfzakYBAu/DeNJBGF7/dEWMkbnPKRL4Ss16QTbDu8jCAlGVmPHGm4VxI ZPew== 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 c184si789843wmh.117.2018.01.15.15.37.47; Mon, 15 Jan 2018 15:37:47 -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 3D6CB68A098; Tue, 16 Jan 2018 01:37:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-3.mx.upcmail.net (vie01a-dmta-pe02-3.mx.upcmail.net [62.179.121.159]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C418E68998B for ; Tue, 16 Jan 2018 01:37:33 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1ebEJr-00084u-2P for ffmpeg-devel@ffmpeg.org; Tue, 16 Jan 2018 00:37:35 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id yndW1w01d0S5wYM01ndXha; Tue, 16 Jan 2018 00:37:32 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 16 Jan 2018 00:37:28 +0100 Message-Id: <20180115233728.15279-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180115233728.15279-1-michael@niedermayer.cc> References: <20180115233728.15279-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/hevc_cabac: Check prefix so as to avoid invalid shifts in coeff_abs_level_remaining_decode() 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" I suspect that this can be limited tighter, but i failed to find anything in the spec that would confirm that. Fixes: 4833/clusterfuzz-testcase-minimized-5302840101699584 Fixes: runtime error: left shift of 134217730 by 4 places cannot be represented in type 'int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevc_cabac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c index 743168500c..faa36d5459 100644 --- a/libavcodec/hevc_cabac.c +++ b/libavcodec/hevc_cabac.c @@ -998,7 +998,7 @@ static av_always_inline int coeff_abs_level_remaining_decode(HEVCContext *s, int } else { int prefix_minus3 = prefix - 3; - if (prefix == CABAC_MAX_BIN) { + if (prefix == CABAC_MAX_BIN || prefix_minus3 + rc_rice_param >= 31) { av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", prefix); return 0; }