From patchwork Sat Sep 9 13:51:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5063 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp1235521jaa; Sat, 9 Sep 2017 06:52:08 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC5fvyFvTu5KgT3BUHo0bP+ExIh3GAdU7qHQaVWv5MegXWYvW9x2Dnjzy9U7QOuxINaLuet X-Received: by 10.28.234.136 with SMTP id g8mr3630185wmi.76.1504965128647; Sat, 09 Sep 2017 06:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504965128; cv=none; d=google.com; s=arc-20160816; b=jVd5R/gLy3NWn1hgsI28Rv2FA2JGcCg+r9R0kMHOpJcUgbIfEUENjRzL/Cpv0dZU7B u7Esf5jjMKmJX6PyRMLztdXLKNsjwHmENr0K+ReZ5dzvnBA2BydDTI7tZTm5Ni22yhAu Dn4igfgjnt0cUdymUdHujMsqcwyXDOq/JjdurPTXtC79flAG+qtJNO0yn8MKNC26hPdS u5y8h1dfPUou5D5E1rmnV4l/EeUE4v2XpIlSxzYJx++1HpRZdKPBDoGKDMVfvz3GNm/P eU8+uJug24iGDH926YIA97hd4+5bhW4EKtJqzckJxlqzpCwpis5Po3q1vM8g6S87EXNB 4gng== 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=tjYU4qk/Dg2IOnajPPWmSwnfPqM5Poet7yDVpavZAQU=; b=vg8zHMinVcpMqOVyUXLrGXc60TKtp3C6ythEo2KrPmAYgvB4kol1svItxkcM9WgzRV MzbnX3yD4veO/YPbF7jN5C3qxgvjK8mL8XwPsWNbIccB8in4Qys0omoWbIRtpNVUybIx zRlE024fesz/VolJ0Nqplb9/GB72zUvs5GuTc/N9x0dcsItyLZEmyXD+0ZlvWf8VCK1W iadZYADXWhZmRCImsDel0UcBHCd2bjr2ehzAC7Qvfgy3yekZiid1blL4/cFdSa0OcXYb xEw0s9tRng3ko8bbQUxQKmanf7JMnm6MLUuIR3+vEXFma3AgKVx3kGcczB+9oios3Mvn Lp5g== 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 d30si3454914wrb.210.2017.09.09.06.52.07; Sat, 09 Sep 2017 06:52:08 -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 2631E689BA0; Sat, 9 Sep 2017 16:52:02 +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 402B9689A93 for ; Sat, 9 Sep 2017 16:51:56 +0300 (EEST) Received: from [172.31.218.39] (helo=vie01a-dmta-pe03-3.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dqgAy-0003gA-HF for ffmpeg-devel@ffmpeg.org; Sat, 09 Sep 2017 15:52:00 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dqgAs-0001uO-U8 for ffmpeg-devel@ffmpeg.org; Sat, 09 Sep 2017 15:51:54 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 7Rrl1w0140S5wYM01RrmT3; Sat, 09 Sep 2017 15:51:46 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 9 Sep 2017 15:51:45 +0200 Message-Id: <20170909135145.13358-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 Subject: [FFmpeg-devel] [PATCH] avcodec/dirac_vlc: limit res_bits in APPEND_RESIDUE() 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: runtime error: left shift of 1073741838 by 1 places cannot be represented in type 'int32_t' (aka 'int') Fixes: 3279/clusterfuzz-testcase-minimized-4564805744590848 Suggested-by: Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dirac_vlc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c index bd37f31f46..bb525f89d8 100644 --- a/libavcodec/dirac_vlc.c +++ b/libavcodec/dirac_vlc.c @@ -37,7 +37,7 @@ #define APPEND_RESIDUE(N, M) \ N |= M >> (N ## _bits); \ - N ## _bits += (M ## _bits) + N ## _bits = (N ## _bits + (M ## _bits)) & 63 int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, int bytes, uint8_t *_dst, int coeffs) @@ -56,9 +56,6 @@ int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, if ((c_idx + 1) > coeffs) return c_idx; - if (res_bits >= RSIZE_BITS) - res_bits = res = 0; - /* res_bits is a hint for better branch prediction */ if (res_bits && l->sign) { int32_t coeff = 1; @@ -99,9 +96,6 @@ int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, if ((c_idx + 1) > coeffs) return c_idx; - if (res_bits >= RSIZE_BITS) - res_bits = res = 0; - if (res_bits && l->sign) { int32_t coeff = 1; APPEND_RESIDUE(res, l->preamble);