From patchwork Thu Aug 17 01:54:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4727 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp1413814vsu; Wed, 16 Aug 2017 18:55:17 -0700 (PDT) X-Received: by 10.28.100.136 with SMTP id y130mr206245wmb.60.1502934917135; Wed, 16 Aug 2017 18:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502934917; cv=none; d=google.com; s=arc-20160816; b=LfWVrMmYdlVPQFTFbWEyySR9JZwxOVDWmnXOBLIuTj/G9wXe8hRPZIDSGQC3VzSWwi YhM7e+c+JfJvepZBvVq4h9tzrgq05p9JwjwRQd5u5h2wDI+B0th1KYEHzcXRhJ0K77pQ M89tDpHyVqN9o9g4x2j/i9hU1VgDGp4+26o43aI2iu2YTW9kE/YJI8Jr1k5sYlXBBxsp CiayDuNI7paGbixhadQmzddT9sQH4Usi0nw6BPoaWbVqC35z/8IQcd0m5Xie0fyIaoBg TOP3L2zQTcUdKxM8sGwtVY+BqKVSlnB41/kAT1SZRNWeAnWXx8MfwErGtWVZka9Zvqth sP1g== 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=7eGUPNySGexjOhPoTOIEHW29DMnOAShSx8XKwY77wYU=; b=vBzX527Y+GUw8by3GqeEbFT+n38JGTPjfeSAp3CQFtn2RJHnw0d9XhvUDvtNMphA3p bsgK/HSrkbIp05m4rD3WY/tp0ShZrBsEphMf0Xg55fpOiBUzETkqaDijPFsUaYhDEHYd dhyFrjkGzK44mhx9zm51fUrzwJlhuZT4resvZb+I8Qe2lmjyAZM0SzBGq8q+wjtXv7ZC smC5pTQ+OKaTeaWSCWquEbUDI4CSDA4quGNbBfWErmIjbbzXAt0T37MUfTfE8zDqKpHX +kKu3yahWBPnPSGvADCCWaD0woVhDjVXJj/xsZGhwn4DHvLven++1shiAIruM3NGLluw /CcA== 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 p6si1536684wrd.379.2017.08.16.18.55.16; Wed, 16 Aug 2017 18:55:17 -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 DB80E6891E9; Thu, 17 Aug 2017 04:55:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (vie01a-dmta-pe04-3.mx.upcmail.net [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 85E6268062A for ; Thu, 17 Aug 2017 04:55:01 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1diA1a-0007c4-8K for ffmpeg-devel@ffmpeg.org; Thu, 17 Aug 2017 03:55:06 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id y1v01v00A0S5wYM011v17D; Thu, 17 Aug 2017 03:55:01 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 17 Aug 2017 03:54:57 +0200 Message-Id: <20170817015457.6723-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817015457.6723-1-michael@niedermayer.cc> References: <20170817015457.6723-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/h264idct_template: Fix integer overflow in ff_h264_idct8_add() 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: 2891/clusterfuzz-testcase-minimized-5881795457318912 Fixes: runtime error: signed integer overflow: 1551827968 - -775913984 cannot be represented in type 'int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/h264idct_template.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index 288107d5a4..3ad58c4a11 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -76,20 +76,20 @@ void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, int16_t *_block, int stride){ for( i = 0; i < 8; i++ ) { - const int a0 = block[i+0*8] + block[i+4*8]; - const int a2 = block[i+0*8] - block[i+4*8]; - const int a4 = (block[i+2*8]>>1) - block[i+6*8]; - const int a6 = (block[i+6*8]>>1) + block[i+2*8]; - - const int b0 = a0 + a6; - const int b2 = a2 + a4; - const int b4 = a2 - a4; - const int b6 = a0 - a6; - - const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1); - const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1); - const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1); - const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1); + const unsigned int a0 = block[i+0*8] + block[i+4*8]; + const unsigned int a2 = block[i+0*8] - block[i+4*8]; + const unsigned int a4 = (block[i+2*8]>>1) - block[i+6*8]; + const unsigned int a6 = (block[i+6*8]>>1) + block[i+2*8]; + + const unsigned int b0 = a0 + a6; + const unsigned int b2 = a2 + a4; + const unsigned int b4 = a2 - a4; + const unsigned int b6 = a0 - a6; + + const int a1 = -block[i+3*8] + (unsigned)block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1); + const int a3 = block[i+1*8] + (unsigned)block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1); + const int a5 = -block[i+1*8] + (unsigned)block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1); + const int a7 = block[i+3*8] + (unsigned)block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1); const int b1 = (a7>>2) + a1; const int b3 = a3 + (a5>>2);