From patchwork Mon Jul 2 18:45: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: 9572 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp285879jad; Mon, 2 Jul 2018 11:46:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmcL7pqvEEHdUIBrNg6jPMJ73MAPoVSUcExB+4U63c9bTcvg/mEW8yJMFfB6ccwdAxz+rN X-Received: by 2002:adf:c321:: with SMTP id n30-v6mr7806710wrf.235.1530557176392; Mon, 02 Jul 2018 11:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530557176; cv=none; d=google.com; s=arc-20160816; b=Y8N57teEzauTIXw/hVxH2wExXiYest6xR90BbdY3UQ9lfSIC0btAsWqTW+ZvYdnRNP ygUB7Uk2Wb59FOfi/8lwh68lMqIXBUoT6kxUC75Hu+v6QzhpQwg+ud/REgC3ruRR0pLp 0kU7RwMvTTeK4zy7C9JggLUf6Jx8LptUO7zifIk1TTDWv17Mk2zsX3e2byrfKfeFhFDl 11O19ESx9R7ofZm00QTmHwOFvFvogJgRY5GigoqM+8UeHUm4wKi/mxeowj6hbyhNFfZP r4ReptfMZwYbHZjT3FK1y9fLq8GIvDnTFQN87ENFGt8EctECeXLJn73MnrJE0mduCrIl KLlA== 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=pIICHoM/4S8Iy9aXs/TraXbu7hEREsd72KVlG/th45Y=; b=Oh7ZiyDAvcNq8FPTrjlcd/QipmBqvKFzigHHvuBJRSGdnDSC0IK8FZz2eneoco30jI 3R+HdiTcWHnu+0e8MaUowlDPBUr2GKoRxved1cougjycpKF/X0RqQPya4hMFrvogPoia u8w78nQlYQ6LKPQPWqAtbGEJK0jeym+BgAHbQHbH1o85UgYNc8esrkhfN8vGBPz5ag5R gSqKiYYjBouVzpDeFmLa2sjLf/6dF8LmVo1b0P7UPMiEEwDyfSx7SnavN8xoW5sePGpE NJurxt3PgLBnV/O9G6mI9WgNo6eeJ4W0wADkQrGqInJkkYBtR/tMIa5fYfRYwz9Jv3WE 79gw== 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 n2-v6si4922383wrr.172.2018.07.02.11.46.15; Mon, 02 Jul 2018 11:46:16 -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 4858868A579; Mon, 2 Jul 2018 21:46:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe08-3.mx.upcmail.net (vie01a-dmta-pe08-3.mx.upcmail.net [84.116.36.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B66168A4AB for ; Mon, 2 Jul 2018 21:46:03 +0300 (EEST) 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 1fa3pu-0008TJ-Kr for ffmpeg-devel@ffmpeg.org; Mon, 02 Jul 2018 20:46:06 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 5um21y0190S5wYM01um3di; Mon, 02 Jul 2018 20:46:03 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 2 Jul 2018 20:45:09 +0200 Message-Id: <20180702184511.12534-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180702184511.12534-1-michael@niedermayer.cc> References: <20180702184511.12534-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Fixes invalid shifts in jpeg2000_decode_packets_po_iteration() 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: shift exponent 47 is too large for 32-bit type 'int' Fixes: 9163/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5661750182543360 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 4071b5ce53..96dab8e176 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1254,10 +1254,10 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2 if (reslevelno >= codsty->nreslevels) continue; - if (yc % (1 << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check + if (yc % (1LL << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check continue; - if (xc % (1 << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check + if (xc % (1LL << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check continue; // check if a precinct exists @@ -1325,10 +1325,10 @@ static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2 uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; - if (yc % (1 << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check + if (yc % (1LL << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check continue; - if (xc % (1 << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check + if (xc % (1LL << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check continue; // check if a precinct exists