From patchwork Wed Sep 20 00:30:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43848 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a886:b0:149:dfde:5c0a with SMTP id ca6csp306979pzb; Tue, 19 Sep 2023 17:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6JKbDMBCaBwmtqmV0NKWmoTuqJrBICjjX00YkDOTs/jJoFcN2NDGFWjRQ4SQ8BMi4udOx X-Received: by 2002:a05:6512:e86:b0:500:7fc7:8521 with SMTP id bi6-20020a0565120e8600b005007fc78521mr1203171lfb.64.1695169860922; Tue, 19 Sep 2023 17:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695169860; cv=none; d=google.com; s=arc-20160816; b=TTpCxo28adDDhRrIJB24Fwx6kOtAL8fWpvsIQKKk8VYBnmDfNKH58tkvWahJxNkyOU xsIJ1tZvZ51PlA5Zn0WOXPQgmS0/J+KJ3I0fUKzCeXo3ZE6Hy6E/LbHXpDPTk9s4qgWO lJ6WTysSSi7dqbmhLX7TX0bGhnjX4FUJp/sUNzd18kthC+S/inJAygcBX+UWc8Zea9EB A4NP6D+ecqW2AnLEf1VRLetX7vMV37bdV7MSbE/AfzPQ9kbdV0ILJDPOA3MKbdYDRbUu RmGdwXyO5rTgLSwydaZNlmG5T1LWUpHb4DwZQE73NOmvMdtFbOSSykuvIApnVkYxGflO 7/rQ== 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; bh=uVq6tCiH8x928JDc84VjSAlrHW6W8FiScj8Desch6CI=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=r5B5U4aJU3FMqJCbL4StaLijRJSv11bAPhXBtdxzab5aQWr4ilA2MJQicLbOGp8uqR ZwNKg4aXZd4xzuO3XaRSfq6v60bXEFF5JZK28Q5mg+QISJrlHJ/WRjOqSynqdaOBsqMx DWyZHFUOhFcg7wfPSQbMgRdY76NJPax68F7mrVPtMJJ5eyFMGZYNcLq1JeCbZtQKy1lF yCzFkytpLdSSiwM76bGVmY/rbdcMirPjvLJ93QWelJPPGk0qXIe/zAv/dt1WIDzuRhlP 7gj3/YUQodQaaXxhFTlpnhkkiQsSrBvXMzXW6yvXJv16q5/i3iTF+5p221av3pxXPwiv TW/g== 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 bo8-20020a0564020b2800b0052a3a1c943csi11338318edb.159.2023.09.19.17.30.57; Tue, 19 Sep 2023 17:31:00 -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 D16BD68C90A; Wed, 20 Sep 2023 03:30:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B197C68C60E for ; Wed, 20 Sep 2023 03:30:36 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id E82D9E0002 for ; Wed, 20 Sep 2023 00:30:35 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 20 Sep 2023 02:30:31 +0200 Message-Id: <20230920003034.7241-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230920003034.7241-1-michael@niedermayer.cc> References: <20230920003034.7241-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/flacdec: Fix integer overflow in "33bit" DECODER_SUBFRAME_FIXED_WIDE() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: UlbKQOwm9+/C Fixes: signed integer overflow: 4 * 2307917133220067266 cannot be represented in type 'long' Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6307690022043648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/flacdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 0569f019b3a..ed2de14d0a9 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -366,19 +366,19 @@ static int decode_subframe_fixed(FLACContext *s, int32_t *decoded, break; \ case 1: \ for (int i = pred_order; i < blocksize; i++) \ - decoded[i] = (int64_t)residual[i] + (int64_t)decoded[i-1];\ + decoded[i] = (uint64_t)residual[i] + (uint64_t)decoded[i-1];\ break; \ case 2: \ for (int i = pred_order; i < blocksize; i++) \ - decoded[i] = (int64_t)residual[i] + 2*(int64_t)decoded[i-1] - (int64_t)decoded[i-2]; \ + decoded[i] = (uint64_t)residual[i] + 2*(uint64_t)decoded[i-1] - (uint64_t)decoded[i-2]; \ break; \ case 3: \ for (int i = pred_order; i < blocksize; i++) \ - decoded[i] = (int64_t)residual[i] + 3*(int64_t)decoded[i-1] - 3*(int64_t)decoded[i-2] + (int64_t)decoded[i-3]; \ + decoded[i] = (uint64_t)residual[i] + 3*(uint64_t)decoded[i-1] - 3*(uint64_t)decoded[i-2] + (uint64_t)decoded[i-3]; \ break; \ case 4: \ for (int i = pred_order; i < blocksize; i++) \ - decoded[i] = (int64_t)residual[i] + 4*(int64_t)decoded[i-1] - 6*(int64_t)decoded[i-2] + 4*(int64_t)decoded[i-3] - (int64_t)decoded[i-4]; \ + decoded[i] = (uint64_t)residual[i] + 4*(uint64_t)decoded[i-1] - 6*(uint64_t)decoded[i-2] + 4*(uint64_t)decoded[i-3] - (uint64_t)decoded[i-4]; \ break; \ default: \ av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order); \