From patchwork Wed Jan 31 18:20:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7458 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp2047129jak; Wed, 31 Jan 2018 10:20:31 -0800 (PST) X-Google-Smtp-Source: AH8x226V1fhdCAuMT2mzFywnO7l/seTgNM1vP9wvbeBxQ2BVNiCv6A9ho55EwmZQ9gZltg9HreB4 X-Received: by 10.28.133.209 with SMTP id h200mr17251582wmd.14.1517422831649; Wed, 31 Jan 2018 10:20:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517422831; cv=none; d=google.com; s=arc-20160816; b=LmHrAjUFgaAjM7fVZIy5O56edT4TLM3M5J0vZlrUY0B/wXXyl4zt7HjNwbAVecguI1 EtgdxJrwaraWtmF9BEhcBRaiUJm33rztC4QsiinsXytOYeASUTwb7OtaCPT2SSCfqJ7b XaXMSN0OM+I0BniXMf7Id9rTunJRwXsisAChmlLCTZbMuwnX766toOczqUCQZc8VnQ9q NzEuJzjqYnGO97PqccXkqxnBN0VJmhSwwQJA6pHEbiGGrdUx3EVrGmp1OrQ7qoyFNi13 5P/WvbhRERQs1FYb3t4R1BLZSo6AvciYpQGHg2Ywtet69uoPsQSwL+oNkCCDPicL5sif LSRA== 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=4J1JBOrX2+6+a9xSnhlCAhV3yUa5w7jDyFGrCxg/SyM=; b=0mS2NdqAhx81Tza97sKUrSvYbSy+eBASGaaZHe5ngT+6LtqlW2yuoTph9dTPZdDpCo xgi5+TmmfnbXfEIS7zxWcE6qPdSanl486roIEPdvcGn9Of1aYlye8U87sqQkivpfQtvI qlZYBUeJzTmOBeaAp+28SsGiCJDlBNENH54zhfY6766I0tbiBz0Xiqpe0aASvdCNIDd5 ip4JUvP99pASox2StyXnQrShB9i7bnF25FcZ0b2isvl1An6alTgo/AMTaG1cXXMTcIvS AHA0bOndyqkz4KzEEbyR8ovzDTItf97n2WDiHddrtg2uOYNs5eiJ0PelfHB/s0Mh/W0T 0K+w== 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 b9si15166627wrh.370.2018.01.31.10.20.30; Wed, 31 Jan 2018 10:20:31 -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 5BEC2689834; Wed, 31 Jan 2018 20:20:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe08-1.mx.upcmail.net (vie01a-dmta-pe08-1.mx.upcmail.net [84.116.36.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8125468834F for ; Wed, 31 Jan 2018 20:20:17 +0200 (EET) 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 1egwze-00017a-FG for ffmpeg-devel@ffmpeg.org; Wed, 31 Jan 2018 19:20:22 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 56LC1x01B0S5wYM016LDdX; Wed, 31 Jan 2018 19:20:13 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 31 Jan 2018 19:20:09 +0100 Message-Id: <20180131182010.8745-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180131182010.8745-1-michael@niedermayer.cc> References: <20180131182010.8745-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr_fixed: Fix overflows in rounding in sbr_hf_assemble() 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: 2052929346 + 204817098 cannot be represented in type 'int' Fixes: 5275/clusterfuzz-testcase-minimized-5367635958038528 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/aacsbr_fixed.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c index 3d5875a469..eeada0b9f2 100644 --- a/libavcodec/aacsbr_fixed.c +++ b/libavcodec/aacsbr_fixed.c @@ -568,7 +568,8 @@ static void sbr_hf_assemble(int Y1[38][64][2], int A = (1-((indexsine+(kx & 1))&2)); int B = (A^(-idx)) + idx; int *out = &Y1[i][kx][idx]; - int shift, round; + int shift; + unsigned round; SoftFloat *in = sbr->s_m[e]; for (m = 0; m+1 < m_max; m+=2) { @@ -581,12 +582,12 @@ static void sbr_hf_assemble(int Y1[38][64][2], } if (shift < 32) { round = 1 << (shift-1); - out[2*m ] += (in[m ].mant * A + round) >> shift; + out[2*m ] += (int)(in[m ].mant * A + round) >> shift; } if (shift2 < 32) { round = 1 << (shift2-1); - out[2*m+2] += (in[m+1].mant * B + round) >> shift2; + out[2*m+2] += (int)(in[m+1].mant * B + round) >> shift2; } } if(m_max&1) @@ -597,7 +598,7 @@ static void sbr_hf_assemble(int Y1[38][64][2], return; } else if (shift < 32) { round = 1 << (shift-1); - out[2*m ] += (in[m ].mant * A + round) >> shift; + out[2*m ] += (int)(in[m ].mant * A + round) >> shift; } } }