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 5F19847E5A for ; Thu, 28 Dec 2023 19:53:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDB4668CC91; Thu, 28 Dec 2023 21:53:22 +0200 (EET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 820F068CA6C for ; Thu, 28 Dec 2023 21:53:16 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id A829020003 for ; Thu, 28 Dec 2023 19:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1703793195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wy5yQyhP3TNf1TKlCmWw0nQYmcHAvWevHDzxh4YzMsA=; b=Ant0RXVPt3onLCRxbJkJeSInZnscFTR+1Ncrc6GD/Pq45Rmz80D+fbjc+QNqgTlkOfTWIZ b9o2eMG2Wym9ogkj7YijTf2hfod63jpHluchj9OdGh/at+YAnqLJzv9gDOgBe9B32ZsSXn j3QpDmKuskAU+jjfpFpEIVjaEeK1H8Oi4rLx7ald8vuDJ7SZsgczRaxCWyB88xCtu6Nyex zpZyuj7SdSifXOz45stQQy8U1ocKVpXiXKV8Z2WAjcuQeG6+sxDtB4go7KRDugWbv3D/I8 pg9oyRtZpTwwFwqA+RZruYRnzzIAlWgXlB15yDd7hzWQMDJNYSFvwyeIEghpKQ== Date: Thu, 28 Dec 2023 20:53:14 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20231228195314.GX6420@pb2> References: <20231226163731.4147-1-michael@niedermayer.cc> <20231226163731.4147-2-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 2/3] avcodec/osq: avoid several signed integer overflows 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="===============3629235374285102325==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3629235374285102325== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Z1EIi0fvCUyWUKja" Content-Disposition: inline --Z1EIi0fvCUyWUKja Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 26, 2023 at 01:56:31PM -0300, James Almer wrote: > On 12/26/2023 1:37 PM, Michael Niedermayer wrote: > > Fixes: signed integer overflow: 178459578 + 2009763270 cannot be repres= ented in type 'int' > > Fixes: 62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzz= er-5013423686287360 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/osq.c | 24 ++++++++++++------------ > > 1 file changed, 12 insertions(+), 12 deletions(-) > >=20 > > diff --git a/libavcodec/osq.c b/libavcodec/osq.c > > index abe15c97f18..f2771c46eb5 100644 > > --- a/libavcodec/osq.c > > +++ b/libavcodec/osq.c > > @@ -222,8 +222,8 @@ static int osq_channel_parameters(AVCodecContext *a= vctx, int ch) > > #define C (-3) > > #define D (-4) > > #define E (-5) > > -#define P2 ((dst[A] + dst[A]) - dst[B]) > > -#define P3 ((dst[A] - dst[B]) * 3 + dst[C]) > > +#define P2 (((unsigned)dst[A] + dst[A]) - dst[B]) > > +#define P3 (((unsigned)dst[A] - dst[B]) * 3 + dst[C]) > > static int do_decode(AVCodecContext *avctx, AVFrame *frame, int decor= relate, int downsample) > > { > > @@ -273,10 +273,10 @@ static int do_decode(AVCodecContext *avctx, AVFra= me *frame, int decorrelate, int > > case 0: > > break; > > case 1: > > - dst[n] +=3D dst[A]; > > + dst[n] +=3D (unsigned)dst[A]; > > break; > > case 2: > > - dst[n] +=3D dst[A] + p; > > + dst[n] +=3D (unsigned)dst[A] + p; > > break; > > case 3: > > dst[n] +=3D P2; > > @@ -291,28 +291,28 @@ static int do_decode(AVCodecContext *avctx, AVFra= me *frame, int decorrelate, int > > dst[n] +=3D P3 + p; > > break; > > case 7: > > - dst[n] +=3D (P2 + P3) / 2 + p; > > + dst[n] +=3D (int)(P2 + P3) / 2 + (unsigned)p; >=20 > Would 2U work for this? It's shorted and more readable that casts > everywhere. Same for most cases below. unsigned and signed division are different -1 / 2 =3D=3D 0 -1 / 2U !=3D 0 thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew .= =2E." --Z1EIi0fvCUyWUKja Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZY3SKgAKCRBhHseHBAsP q0pbAJ9KvyIYWWeSPDJ+JgyTaj9Hhky5AgCeM1F3MUwXxX1KoM7ii0R5XxefUsg= =jgav -----END PGP SIGNATURE----- --Z1EIi0fvCUyWUKja-- --===============3629235374285102325== 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". --===============3629235374285102325==--