From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D8D4246119 for ; Sat, 6 May 2023 15:08:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 477B368C129; Sat, 6 May 2023 18:08:22 +0300 (EEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A62768B012 for ; Sat, 6 May 2023 18:08:15 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id AE5F7FF807 for ; Sat, 6 May 2023 15:08:14 +0000 (UTC) Date: Sat, 6 May 2023 17:08:13 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230506150813.GD4538@pb2> References: <20230416164830.15664-1-michael@niedermayer.cc> <20230416164830.15664-5-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============4215930147951483839==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4215930147951483839== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eqp4TxRxnD4KrmFZ" Content-Disposition: inline --eqp4TxRxnD4KrmFZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 05, 2023 at 07:36:05PM -0300, James Almer wrote: > On 4/16/2023 1:48 PM, Michael Niedermayer wrote: > > Fixes: signed integer overflow: 3011809745540902265 + 63234527308835717= 25 cannot be represented in type 'long' > > Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuz= zer-6687553022722048 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/flacdec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > 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 =3D pred_order; i < s->blocksize; i++, decoded++) { > > int64_t sum =3D 0; > > for (j =3D 0; j < pred_order; j++) > > - sum +=3D (int64_t)coeffs[j] * decoded[j]; > > + sum +=3D (int64_t)coeffs[j] * (uint64_t)decoded[j]; >=20 > Why not instead do >=20 > sum =3D av_sat_add64(sum, (int64_t)coeffs[j] * decoded[j]); Why should this be clipping ? flac is a lossless codec, i see nothing in the specification that calls for cliping. >=20 > 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? it can be shuffled around to achieve the same, do you prefer=20 coeffs[j] * (uint64_t)decoded[j]; ? =20 thx [...]=20 --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Any man who breaks a law that conscience tells him is unjust and willingly= =20 accepts the penalty by staying in jail in order to arouse the conscience of= =20 the community on the injustice of the law is at that moment expressing the= =20 very highest respect for law. - Martin Luther King Jr --eqp4TxRxnD4KrmFZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZFZtWAAKCRBhHseHBAsP qwotAJ9Co6UW2Kb2xrmq4OJZSJzBfts4kgCgh1M68k2Sz0rXMZO+h7FqxVf6uJ4= =phLB -----END PGP SIGNATURE----- --eqp4TxRxnD4KrmFZ-- --===============4215930147951483839== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============4215930147951483839==--