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 CE29A453A0 for ; Fri, 28 Apr 2023 23:04:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89EE668C036; Sat, 29 Apr 2023 02:04:41 +0300 (EEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CEC468BF86 for ; Sat, 29 Apr 2023 02:04:35 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 62A911C0003 for ; Fri, 28 Apr 2023 23:04:34 +0000 (UTC) Date: Sat, 29 Apr 2023 01:04:32 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230428230432.GH275832@pb2> References: <20230428044248.42988-1-etemesicaleb@gmail.com> MIME-Version: 1.0 In-Reply-To: <20230428044248.42988-1-etemesicaleb@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: Ensure calculation of buf_size cannot 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="===============1972076253344912895==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1972076253344912895== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RbAp84Sx/Z5HOs1D" Content-Disposition: inline --RbAp84Sx/Z5HOs1D Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 28, 2023 at 07:42:48AM +0300, etemesicaleb@gmail.com wrote: > From: caleb >=20 > --- > libavcodec/jpeg2000htdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c > index 51cd96e0f1..d77293ddd8 100644 > --- a/libavcodec/jpeg2000htdec.c > +++ b/libavcodec/jpeg2000htdec.c > @@ -595,7 +595,7 @@ static int jpeg2000_decode_ht_cleanup_segment(const J= peg2000DecoderContext *s, > const uint16_t quad_width =3D ff_jpeg2000_ceildivpow2(width, 1); > const uint16_t quad_height =3D ff_jpeg2000_ceildivpow2(height, 1); > =20 > - size_t buf_size =3D 4 * quad_width * quad_height; > + size_t buf_size =3D 4UL * quad_width * quad_height; The only caller asserts that width and height are <=3D 1024 so this change should not be needed 4 is an int and int is by POSIX 32bit at least if you want to make the code "nicer", i would suggest changing the quad_width and quad_height to int. uint16_t should generally only be used if theres a reason. (space for an array can be a reason so can it be to intentionally truncate to 16bit) But needing only 16bit is a bad reason. uint16_t is generally not faster, in fact C treats it like a int an= yway thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire --RbAp84Sx/Z5HOs1D Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZExQ/AAKCRBhHseHBAsP qyx2AJ9dfAWP31IGwuD+NZHnlJvwyxi5JACghkDETljsRIonkXGIuFyerZMwVv0= =BYFo -----END PGP SIGNATURE----- --RbAp84Sx/Z5HOs1D-- --===============1972076253344912895== 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". --===============1972076253344912895==--