From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id E8AB246108
	for <ffmpegdev@gitmailbox.com>; Fri,  5 May 2023 22:36:11 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F291068B74D;
	Sat,  6 May 2023 01:36:08 +0300 (EEST)
Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com
 [209.85.160.45])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A112868A0A2
 for <ffmpeg-devel@ffmpeg.org>; Sat,  6 May 2023 01:36:02 +0300 (EEST)
Received: by mail-oa1-f45.google.com with SMTP id
 586e51a60fabf-18665c1776dso1972710fac.2
 for <ffmpeg-devel@ffmpeg.org>; Fri, 05 May 2023 15:36:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1683326161; x=1685918161;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :from:to:cc:subject:date:message-id:reply-to;
 bh=nJjq1gEo1v9WrinaO1n+juYv6L7/KSPh3XVQUCk5DRk=;
 b=phILd4kKbzxs6TE/CPzG5obwDQwOng/JzgRXvUc7AIsIxxsyMIYsvLZSz4slLG5ym/
 yVUcskwByOEoKbm6HDT5tXDagddIPvK2Qt4tnmepvsIre1jO02KwdI2pbvQtnS+e4FQs
 Yp6z0ScWOfyd9YM1KKQsH+ZWo1uRi0dBMiqLQbG7SktoCHuVXTke9+/+hQDwE+xg+gZq
 lOuODoKcoo6GASnKfMCgXdZWfIKH/RMSGBvUg/Ogvle+QGnkvx/KSuWocC25wz/QgzFT
 OGK9Ff/NqGGtbxVkGu9t1K/nHRq3NNWHmBwc9rNDStyxKwPxhreE1LvAXZ+ppWXU72MX
 uHXA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1683326161; x=1685918161;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=nJjq1gEo1v9WrinaO1n+juYv6L7/KSPh3XVQUCk5DRk=;
 b=XqbHHECma01jRu1BxZxSzXXFNrQ9gLFJV2Ej4htNYqdHMgwVaEkK25PoGMvL4gc33u
 PQ3ZkY+lCrCeELYbbLii+euQ/tmUC1bVcviYcxW/K3PMRXxL9szrk+3M4OsRuGDC7rf5
 pNHrRHO2ASBNJsFNsZ+WbG2Z7u3YtLtUoQ/KfNxvS1fQG4ICt8Mcj6tETxMmX8S4Xj9W
 DPyHWKQ8B6UBoYlo/osrlTjHqDrtTYiPxi1bofRBAWLhWQZsTr0ygXlvJ23cRkKZJOcv
 h5K9T8S4cmTutff5eCz8UZ+JJzve5Qk+VXn/6+5HPelFIjtS+oS0kE5x8yeJmTx2duV6
 /BHw==
X-Gm-Message-State: AC+VfDxhjJnCHwoVGv2ln0jz3AKKlhd2tt6J14+go+XMjM5k82h5ajmw
 RtIpBxY67+uf24kbTUEXM/VnId9nLlQ=
X-Google-Smtp-Source: ACHHUZ7WFos6adH2LJaGrNkivTLIvTGv/6mcdG1gRP5jxFC2WohaEvyn33Klg0SOMQd3qwDD4vQd7A==
X-Received: by 2002:a05:6870:1a91:b0:184:1b1a:6677 with SMTP id
 ef17-20020a0568701a9100b001841b1a6677mr1737621oab.24.1683326160733; 
 Fri, 05 May 2023 15:36:00 -0700 (PDT)
Received: from [192.168.0.12] (host197.190-225-105.telecom.net.ar.
 [190.225.105.197]) by smtp.gmail.com with ESMTPSA id
 g5-20020a05687085c500b00187e500e7b3sm2348090oal.49.2023.05.05.15.35.59
 for <ffmpeg-devel@ffmpeg.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 05 May 2023 15:36:00 -0700 (PDT)
Message-ID: <cb0a1de4-63bc-b8cc-585a-daa075610d55@gmail.com>
Date: Fri, 5 May 2023 19:36:05 -0300
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.10.1
Content-Language: en-US
To: ffmpeg-devel@ffmpeg.org
References: <20230416164830.15664-1-michael@niedermayer.cc>
 <20230416164830.15664-5-michael@niedermayer.cc>
From: James Almer <jamrial@gmail.com>
In-Reply-To: <20230416164830.15664-5-michael@niedermayer.cc>
Subject: Re: [FFmpeg-devel] [PATCH 05/11] avcodec/flacdec: Fix signed
 integre overflow
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/cb0a1de4-63bc-b8cc-585a-daa075610d55@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On 4/16/2023 1:48 PM, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 3011809745540902265 + 6323452730883571725 cannot be represented in type 'long'
> Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6687553022722048
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavcodec/flacdec.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
> index cc778a8dff1..524a0469495 100644
> --- a/libavcodec/flacdec.c
> +++ b/libavcodec/flacdec.c
> @@ -513,7 +513,7 @@ static int decode_subframe_lpc_33bps(FLACContext *s, int64_t *decoded,
>       for (i = pred_order; i < s->blocksize; i++, decoded++) {
>           int64_t sum = 0;
>           for (j = 0; j < pred_order; j++)
> -            sum += (int64_t)coeffs[j] * decoded[j];
> +            sum += (int64_t)coeffs[j] * (uint64_t)decoded[j];

Why not instead do

sum = av_sat_add64(sum, (int64_t)coeffs[j] * decoded[j]);

Also, decoded[j] is an int64_t, so wouldn't coeffs[j] be promoted if you 
swap the order in the multiplication, thus saving the cast?

>           decoded[j] = residual[i] + (sum >> qlevel);
>       }
>   
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".