From patchwork Wed Jul 19 00:44:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4363 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp140164vsb; Tue, 18 Jul 2017 17:44:56 -0700 (PDT) X-Received: by 10.28.55.195 with SMTP id e186mr3942073wma.26.1500425096675; Tue, 18 Jul 2017 17:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500425096; cv=none; d=google.com; s=arc-20160816; b=XyK4yEMKNtfrna/63UD2eloSc8tUpmAYiaER77pybjMX9aM+FPqyv4CRFy27JHLkpD RAeox3ASrTv6LGVSKoyNONx2JC2J/uRokS+lZjSADT1lZevvvufQM5Ds8xwBMdbx1bXi 9g/InKv7S30zyFMIPlShm2+zehf4OcKJew6QiUP5/lNW4+DHcQHQJmr4X0wSThFS3aCV QhnIh4oCc2s4iCbn+l2QdCnPA8Gqq1NrpGsxD1VF2FkfZhmzWPn+RZmR4UHohgUpm8rQ v7APKC19TpDEv7QEvEgg2JplEpT2asGfVacds/1ibdyQ087EeXWAdVVcWeY4m8mLnBgm G81w== 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=irn3YL11P7qtwMHGHUcN5k6c0+wVN0xhqn8Hm3yQrvw=; b=OCY8k8xorADMr/aqETkLm6zzJzn3HNms12/MWTF3DT6CQWCGXpHZPoV8vjzeYq2fQ1 KXVuww4xVLj7zv+hT5nAQ8xseboiFZjjAmIKcgNzyZ4oDG0z3pyiFXr5OY0/XxkWOtRu R8pkizL4YSiF2gojJfLmERUub7HO+w6PmdGPBM+OZqSaTORfhiK4x2NNjKTrlzh93fhI rvGWsxJ2jtnWdmlOmDllS7JQdOdAEgDYquH+NuHrzVddE4dUPSOq7+dZvvP+ijoMgEH5 onNrA3fmgFgDwZuVf7YIwMGrwwxenGDlRAfuUM4x8x3KQ3BsOaaoS7tHPWZa0ngOwsww G1ww== 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 y18si4405357wmh.35.2017.07.18.17.44.56; Tue, 18 Jul 2017 17:44:56 -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 62D596898D9; Wed, 19 Jul 2017 03:44:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (vie01a-qmta-pe02-3.mx.upcmail.net [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B292568971E for ; Wed, 19 Jul 2017 03:44:33 +0300 (EEST) Received: from [172.31.218.49] (helo=vie01a-dmta-pe05-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dXd6X-0004hk-2n for ffmpeg-devel@ffmpeg.org; Wed, 19 Jul 2017 02:44:41 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dXd6R-0006GQ-BW for ffmpeg-devel@ffmpeg.org; Wed, 19 Jul 2017 02:44:35 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id mQkY1v00M0S5wYM01QkZXi; Wed, 19 Jul 2017 02:44:33 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 19 Jul 2017 02:44:30 +0200 Message-Id: <20170719004430.6747-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170719004430.6747-1-michael@niedermayer.cc> References: <20170719004430.6747-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/dirac_vlc: Fix undefined shift 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: shift exponent 64 is too large for 64-bit type 'residual' (aka 'unsigned long') Fixes: 2674/clusterfuzz-testcase-minimized-4999700518273024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dirac_vlc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c index 336d22a182..773f720858 100644 --- a/libavcodec/dirac_vlc.c +++ b/libavcodec/dirac_vlc.c @@ -216,9 +216,14 @@ static void generate_offset_lut(DiracGolombLUT *lut, int off) INIT_RESIDUE(res); SET_RESIDUE(res, idx, LUT_BITS); - l->preamble = CONVERT_TO_RESIDUE(res >> (RSIZE_BITS - off), off); l->preamble_bits = off; - l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1; + if (off) { + l->preamble = CONVERT_TO_RESIDUE(res >> (RSIZE_BITS - off), off); + l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1; + } else { + l->preamble = 0; + l->sign = 1; + } search_for_golomb(l, res << off, LUT_BITS - off); }