From patchwork Sat Jan 13 23:39:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7278 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp1167444jaa; Sat, 13 Jan 2018 15:40:17 -0800 (PST) X-Google-Smtp-Source: ACJfBotdnrgstsjM695xNRuqygEStgizHzDBHVfbGizfu3Kya56l1X+cl9TiyP7HeBLTxk7pKrTX X-Received: by 10.28.21.66 with SMTP id 63mr7817407wmv.44.1515886817634; Sat, 13 Jan 2018 15:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515886817; cv=none; d=google.com; s=arc-20160816; b=kRnTAjzo/gRPb6+nlBpD/Y0/Ntkv3YnWJb58YbYXOEMIMjz8OcF7DGHA7VAMwpZDh6 1NCSLiYl6AXs0sJxrKinfZlpKuyf9Mt+5t3WT5THmOWt2Czl6tJ2h9RygywScteAuudw b4YacIVrSWIx0O6m/1GbaqYAr7hw0FwsXeOE60O6vqV2NhnFFwpSa27K0ry0sYg2RsmD ha06Bc8bxmu+Jc9e109hdYapBiyVgn0XbaYfIyFlTWeHQhnSlqFc5GXaNt8kZIUdnBEZ 2vRAqqV0qJXZfHHkWq+jo2xWKDdEic3u1ANit4ugZh4p3DbjLvLP63z5FQJxscsvQ4bd MJcg== 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=oB2/VsI4WovXzI+oQTInogXE23AmEwezwvnPwP5dVUU=; b=KOo32R4mGiGEDeTzYdDyQNJvUmc1tlocl0+VXuRpI1YfNCrKFgYYekB+T/lXS6CNdr 9uvAcvT1grbtIxRhj7Bzjdx73lg0hrYvtawnuwSWKpuie7zYCcTVTKAqwcXRbjfH8uBX sEtAfw9lR4yzTtxZB47q4RHUJ3BkBSD6lCfWm9ueUHLFIM/RlRQKGn3AJFRY4jnxZxuI ZkDt1/p6+V/hnGwhIWg5nHtMrbI/eKJytyLNUVaSwWO+z4jIRRE8J4mjYsoENNUWQbPl rrMgzq/quZqnVeBczVxyTKg44EYQiJfIQuMY1B57DUvGys8mMnOM4XC869bqzfaFcZrJ P76A== 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 i67si2724590wmi.164.2018.01.13.15.40.02; Sat, 13 Jan 2018 15:40:17 -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 2D312689DBE; Sun, 14 Jan 2018 01:40:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-2.mx.upcmail.net (vie01a-qmta-pe02-2.mx.upcmail.net [62.179.121.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32ED9689BE6 for ; Sun, 14 Jan 2018 01:39:53 +0200 (EET) Received: from [172.31.218.54] (helo=vie01a-dmta-pe08-3.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eaVOz-0004P7-RK for ffmpeg-devel@ffmpeg.org; Sun, 14 Jan 2018 00:39:53 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eaVOu-0000MT-8r for ffmpeg-devel@ffmpeg.org; Sun, 14 Jan 2018 00:39:48 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id xzfl1w00E0S5wYM01zfmxX; Sun, 14 Jan 2018 00:39:46 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 14 Jan 2018 00:39:41 +0100 Message-Id: <20180113233941.9407-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180113233941.9407-1-michael@niedermayer.cc> References: <20180113233941.9407-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/wavpack: Fix integer overflows in wv_unpack_stereo / mono 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: signed integer overflow: 2146276249 + 1487583 cannot be represented in type 'int' Fixes: 4823/clusterfuzz-testcase-minimized-4551896611160064 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/wavpack.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index a117e8aa81..d5e1e07b74 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -433,8 +433,8 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10); R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10); } else { - L2 = L + ((int)(s->decorr[i].weightA * (unsigned)A + 512) >> 10); - R2 = R + ((int)(s->decorr[i].weightB * (unsigned)B + 512) >> 10); + L2 = L + (unsigned)((int)(s->decorr[i].weightA * (unsigned)A + 512) >> 10); + R2 = R + (unsigned)((int)(s->decorr[i].weightB * (unsigned)B + 512) >> 10); } if (A && L) s->decorr[i].weightA -= ((((L ^ A) >> 30) & 2) - 1) * s->decorr[i].delta; @@ -446,7 +446,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, if (type != AV_SAMPLE_FMT_S16P) L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10); else - L2 = L + ((int)(s->decorr[i].weightA * (unsigned)s->decorr[i].samplesA[0] + 512) >> 10); + L2 = L + (unsigned)((int)(s->decorr[i].weightA * (unsigned)s->decorr[i].samplesA[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L); L = L2; if (type != AV_SAMPLE_FMT_S16P) @@ -460,7 +460,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, if (type != AV_SAMPLE_FMT_S16P) R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10); else - R2 = R + ((int)(s->decorr[i].weightB * (unsigned)s->decorr[i].samplesB[0] + 512) >> 10); + R2 = R + (unsigned)((int)(s->decorr[i].weightB * (unsigned)s->decorr[i].samplesB[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, s->decorr[i].samplesB[0], R); R = R2; @@ -472,7 +472,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, if (type != AV_SAMPLE_FMT_S16P) L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10); else - L2 = L + ((int)(s->decorr[i].weightA * (unsigned)R2 + 512) >> 10); + L2 = L + (unsigned)((int)(s->decorr[i].weightA * (unsigned)R2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, R2, L); L = L2; s->decorr[i].samplesB[0] = L; @@ -554,7 +554,7 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, if (type != AV_SAMPLE_FMT_S16P) S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10); else - S = T + ((int)(s->decorr[i].weightA * (unsigned)A + 512) >> 10); + S = T + (unsigned)((int)(s->decorr[i].weightA * (unsigned)A + 512) >> 10); if (A && T) s->decorr[i].weightA -= ((((T ^ A) >> 30) & 2) - 1) * s->decorr[i].delta; s->decorr[i].samplesA[j] = T = S;