From patchwork Tue Feb 28 21:07:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2703 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.149 with SMTP id x21csp1629689vsf; Tue, 28 Feb 2017 13:07:51 -0800 (PST) X-Received: by 10.223.160.180 with SMTP id m49mr4584154wrm.167.1488316071080; Tue, 28 Feb 2017 13:07:51 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p5si3867831wrd.242.2017.02.28.13.07.50; Tue, 28 Feb 2017 13:07:51 -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 8E7A36891D1; Tue, 28 Feb 2017 23:07:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-3.mx.upcmail.net (vie01a-dmta-pe02-3.mx.upcmail.net [62.179.121.159]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F245688374 for ; Tue, 28 Feb 2017 23:07:30 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1ciozk-0003om-8Z for ffmpeg-devel@ffmpeg.org; Tue, 28 Feb 2017 22:07:40 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id qM7f1u0090S5wYM01M7gwe; Tue, 28 Feb 2017 22:07:40 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 28 Feb 2017 22:07:36 +0100 Message-Id: <20170228210738.19786-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/h264idct_template: Fix several runtime error: signed integer overflow 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: 689/clusterfuzz-testcase-6029352737177600 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/h264idct_template.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index 9c5a43ce4f..c62716090c 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -261,15 +261,15 @@ void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int for(i=0; i<4; i++){ const int offset= x_offset[i]; - const int z0= temp[4*0+i] + temp[4*2+i]; - const int z1= temp[4*0+i] - temp[4*2+i]; - const int z2= temp[4*1+i] - temp[4*3+i]; - const int z3= temp[4*1+i] + temp[4*3+i]; - - output[stride* 0+offset]= ((((z0 + z3)*qmul + 128 ) >> 8)); - output[stride* 1+offset]= ((((z1 + z2)*qmul + 128 ) >> 8)); - output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8)); - output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8)); + const SUINT z0= temp[4*0+i] + temp[4*2+i]; + const SUINT z1= temp[4*0+i] - temp[4*2+i]; + const SUINT z2= temp[4*1+i] - temp[4*3+i]; + const SUINT z3= temp[4*1+i] + temp[4*3+i]; + + output[stride* 0+offset]= (int)((z0 + z3)*qmul + 128 ) >> 8; + output[stride* 1+offset]= (int)((z1 + z2)*qmul + 128 ) >> 8; + output[stride* 4+offset]= (int)((z1 - z2)*qmul + 128 ) >> 8; + output[stride* 5+offset]= (int)((z0 - z3)*qmul + 128 ) >> 8; } #undef stride }