From patchwork Fri Sep 27 17:23:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 15336 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 436AE447D2F for ; Fri, 27 Sep 2019 20:25:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2DB9F68A5C6; Fri, 27 Sep 2019 20:25:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-1.mx.upcmail.net (vie01a-dmta-pe02-1.mx.upcmail.net [62.179.121.157]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6722C689E19 for ; Fri, 27 Sep 2019 20:25:24 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1iDtzg-0009ot-1H for ffmpeg-devel@ffmpeg.org; Fri, 27 Sep 2019 19:25:24 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Dtyiik0kiwlysDtyiiONtM; Fri, 27 Sep 2019 19:24:24 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=ZacC-_6MOsrZL1LWIyEA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 27 Sep 2019 19:23:50 +0200 Message-Id: <20190927172350.2095-11-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190927172350.2095-1-michael@niedermayer.cc> References: <20190927172350.2095-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfBbOYM//ofXoEPYfl8pRRBag/v55SrKiM0jGhoP0x9GrYOqPeSj8cbrSe35ruhWaJkd4CWkbUM45+KoqimiULLIIjs991vWjNVI73waoJJ7kzN1vlkv9 RQ9q18bNNooxk+OVsaGbcqTud5GPJSmN1xUULp3CVI/tewEacMF/3cHa Subject: [FFmpeg-devel] [PATCH 11/11] avcodec/sbcdec: Fix integer overflows in sbc_synthesize_eight() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: signed integer overflow: 518484152 + 1868182638 cannot be represented in type 'int' Fixes: 17732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SBC_fuzzer-5663738132168704 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sbcdec.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c index 937946e2d2..23226d5155 100644 --- a/libavcodec/sbcdec.c +++ b/libavcodec/sbcdec.c @@ -270,14 +270,14 @@ static inline void sbc_synthesize_eight(struct sbc_decoder_state *state, /* Distribute the new matrix value to the shifted position */ v[offset[i]] = - ( ff_synmatrix8[i][0] * frame->sb_sample[blk][ch][0] + - ff_synmatrix8[i][1] * frame->sb_sample[blk][ch][1] + - ff_synmatrix8[i][2] * frame->sb_sample[blk][ch][2] + - ff_synmatrix8[i][3] * frame->sb_sample[blk][ch][3] + - ff_synmatrix8[i][4] * frame->sb_sample[blk][ch][4] + - ff_synmatrix8[i][5] * frame->sb_sample[blk][ch][5] + - ff_synmatrix8[i][6] * frame->sb_sample[blk][ch][6] + - ff_synmatrix8[i][7] * frame->sb_sample[blk][ch][7] ) >> 15; + (int)( (unsigned)ff_synmatrix8[i][0] * frame->sb_sample[blk][ch][0] + + (unsigned)ff_synmatrix8[i][1] * frame->sb_sample[blk][ch][1] + + (unsigned)ff_synmatrix8[i][2] * frame->sb_sample[blk][ch][2] + + (unsigned)ff_synmatrix8[i][3] * frame->sb_sample[blk][ch][3] + + (unsigned)ff_synmatrix8[i][4] * frame->sb_sample[blk][ch][4] + + (unsigned)ff_synmatrix8[i][5] * frame->sb_sample[blk][ch][5] + + (unsigned)ff_synmatrix8[i][6] * frame->sb_sample[blk][ch][6] + + (unsigned)ff_synmatrix8[i][7] * frame->sb_sample[blk][ch][7] ) >> 15; } /* Compute the samples */ @@ -286,16 +286,16 @@ static inline void sbc_synthesize_eight(struct sbc_decoder_state *state, /* Store in output, Q0 */ AV_WN16A(&output_frame->data[ch][blk * 16 + i * 2], av_clip_int16( - ( v[offset[i] + 0] * ff_sbc_proto_8_80m0[idx + 0] + - v[offset[k] + 1] * ff_sbc_proto_8_80m1[idx + 0] + - v[offset[i] + 2] * ff_sbc_proto_8_80m0[idx + 1] + - v[offset[k] + 3] * ff_sbc_proto_8_80m1[idx + 1] + - v[offset[i] + 4] * ff_sbc_proto_8_80m0[idx + 2] + - v[offset[k] + 5] * ff_sbc_proto_8_80m1[idx + 2] + - v[offset[i] + 6] * ff_sbc_proto_8_80m0[idx + 3] + - v[offset[k] + 7] * ff_sbc_proto_8_80m1[idx + 3] + - v[offset[i] + 8] * ff_sbc_proto_8_80m0[idx + 4] + - v[offset[k] + 9] * ff_sbc_proto_8_80m1[idx + 4] ) >> 15)); + (int)( (unsigned)v[offset[i] + 0] * ff_sbc_proto_8_80m0[idx + 0] + + (unsigned)v[offset[k] + 1] * ff_sbc_proto_8_80m1[idx + 0] + + (unsigned)v[offset[i] + 2] * ff_sbc_proto_8_80m0[idx + 1] + + (unsigned)v[offset[k] + 3] * ff_sbc_proto_8_80m1[idx + 1] + + (unsigned)v[offset[i] + 4] * ff_sbc_proto_8_80m0[idx + 2] + + (unsigned)v[offset[k] + 5] * ff_sbc_proto_8_80m1[idx + 2] + + (unsigned)v[offset[i] + 6] * ff_sbc_proto_8_80m0[idx + 3] + + (unsigned)v[offset[k] + 7] * ff_sbc_proto_8_80m1[idx + 3] + + (unsigned)v[offset[i] + 8] * ff_sbc_proto_8_80m0[idx + 4] + + (unsigned)v[offset[k] + 9] * ff_sbc_proto_8_80m1[idx + 4] ) >> 15)); } }