From patchwork Wed Feb 17 17:10:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 25721 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:6d42:0:0:0:0:0 with SMTP id i63csp2198272ybc; Wed, 17 Feb 2021 09:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5WKC5W/Px6MraSMYSSiR6H94FUIB35qfyUerkMV3l2VkBkt/iCXR7XtEBJICWcEzHFX7t X-Received: by 2002:aa7:d812:: with SMTP id v18mr14132266edq.211.1613582246646; Wed, 17 Feb 2021 09:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613582246; cv=none; d=google.com; s=arc-20160816; b=tgI+OgjMZ2rYIlLWSsftn7ENPOIwu+DGzZ4Tjqgbij1Jeg9FOrI4Pq+2qb1kkAoj1t kOLTSHKzA3b2iLeJu7aNUhMah48DNJCmoLdWbJfXWVQLK6q88Rjk04OJyMoB2aD9XDMt 9zLYG/lgLzEdd8JXaOgc2eGh/TSmfT0Y8FJbMYh91NBgtswc/ASJiJeDX3RdoYv5+V+C +CWpzInSRCKBPi633oltuwyZn+MfNmFB4GoQnvlxO04FX28x/NvCDohj13HoxXdsjfld NtH1NDM2no/G8wvjscfZhTN8JZkIN3F0ODD+VINuziZFgSEJi3m2rgd/BuCCwhAi8erU IKUA== 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:message-id:date:to:from:delivered-to; bh=nuXjM9RPVZFkcylklhAFzBU24UdT/kxm0H+CVvljQ+Q=; b=wUeJoRwalkgvZz2ZX31hpCi9sR9pcplBd1SM+8BjcK9dARlNt4NZQaTLna8hrZNyCg iJEUZML45BejOXMN2Fp6GXZsOjSxgfGIO9klhCFVfWY/pGS6qlDtRKjHJ3GSst5WZjEm ZQTr7JCgxG18mA5lgo1XA3rSsNRHI3By5UhJousmbrqdGrF8mFJGmtxr3J/EY9HdKnMa 5KqVH6rBJzWJ8FQy4sNa27Q8tBB9EXEftCrVyUv1SMyoRIcFZf/IBXl4Vpvgbsl/qwC6 8ljCrIgL1A0DwdqNDZkx6viROOP14rZbxJDyEM+aaSiHzPxs3qUsJ4tqR9I1wFStUNVq ZR/Q== 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 dn4si2415414ejc.353.2021.02.17.09.17.25; Wed, 17 Feb 2021 09:17:26 -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 7578668A148; Wed, 17 Feb 2021 19:17:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA8DA6804E5 for ; Wed, 17 Feb 2021 19:17:17 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lCQMX-000ALx-0I for ffmpeg-devel@ffmpeg.org; Wed, 17 Feb 2021 18:11:41 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id CQLYlbNaRljeHCQLYlLR2V; Wed, 17 Feb 2021 18:10:41 +0100 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=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=_fniHbI0X_nVaSWN76wA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 17 Feb 2021 18:10:40 +0100 Message-Id: <20210217171040.16388-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfJsFoUj6n99qdb6YA/HvaFfcYx04dPsV/a1hSwcpkn2VIZehMxysdOkO09bJTMPN9RT+xriOZ1hBoZfgMymJWrSq8sZACZdDixxp/gwqxebNjbyGcLx2 VVm0m+VPZ2axKZ/V3h9djKavkNSefh66/QuG8hbt91DXKlbYbQhv1IrL Subject: [FFmpeg-devel] [PATCH] avcodec/cfhd: Fix negative shift in cfhd_decode() 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" X-TUID: OvqjOmQZCtLe Content-Length: 2278 Fixes: left shift of negative value -1 Fixes: 30714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4867823371419648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cfhd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index dfd56ae6ed..1f2ee853c1 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -811,7 +811,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, const uint16_t q = s->quantisation; for (i = 0; i < run; i++) { - *coeff_data |= coeff << 8; + *coeff_data |= coeff * 256; *coeff_data++ *= q; } } else { @@ -842,7 +842,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, const uint16_t q = s->quantisation; for (i = 0; i < run; i++) { - *coeff_data |= coeff << 8; + *coeff_data |= coeff * 256; *coeff_data++ *= q; } } else {