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 AB94641D1E for ; Sun, 20 Mar 2022 14:07:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 381C268AF2A; Sun, 20 Mar 2022 16:07:08 +0200 (EET) 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 6258C68A7AD for ; Sun, 20 Mar 2022 16:07:01 +0200 (EET) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 969AAFF803 for ; Sun, 20 Mar 2022 14:07:00 +0000 (UTC) Date: Sun, 20 Mar 2022 15:06:59 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220320140659.GF2829255@pb2> References: <20220312235227.19626-1-michael@niedermayer.cc> <20220312235227.19626-2-michael@niedermayer.cc> <20220319225052.GD2829255@pb2> <92611726582961bafbb001a9c85baf07e93dbf81.camel@acc.umu.se> MIME-Version: 1.0 In-Reply-To: <92611726582961bafbb001a9c85baf07e93dbf81.camel@acc.umu.se> Subject: Re: [FFmpeg-devel] [PATCH 2/4] avformat/mxfdec: Check count in mxf_read_strong_ref_array() 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="===============9117814018961418610==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============9117814018961418610== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gLMrnQYOa3AOROig" Content-Disposition: inline --gLMrnQYOa3AOROig Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 20, 2022 at 02:05:41PM +0100, Tomas H=E4rdin wrote: > l=F6r 2022-03-19 klockan 23:50 +0100 skrev Michael Niedermayer: [...] > >=20 > >=20 > > >=20 > > > > + > > > > +=A0=A0=A0 //avio_read() used int > > > > +=A0=A0=A0 if (c > INT_MAX / sizeof(UID)) > > > > +=A0=A0=A0=A0=A0=A0=A0 return AVERROR_PATCHWELCOME; > > > > +=A0=A0=A0 *count =3D c; > > > > + > > >=20 > > > This should already be caught by av_calloc(), no? > >=20 > > the API as in the documentation of av_calloc() does not gurantee > > this.=A0 >=20 > Yes it does: >=20 > The allocated memory will have size `size * nmemb` bytes. > [...] > `NULL` if the block cannot be allocated void *av_calloc(size_t nmemb, size_t size) size_t can be larger than int, so size * nmemb may be larger than INT_MAX >=20 > > Its bad practice if we write code that depends on some implementation > > of some code in a diferent module/lib >=20 > If av_calloc() does not guarantee this then it is useless. It is used > precisely for this all over the place. Are you going to change every > use of av_calloc() in mxfdec in the same way? well, when max_alloc_size is set above INT_MAX=20 then int checks will become needed when these values ever get stored in ints. For example here avio_read() has a int argument that is set to the product of the 2. Or all such ints need to be changed to something bigger thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato --gLMrnQYOa3AOROig Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYjc0/wAKCRBhHseHBAsP qw6SAKCBfE+1pq69777vn1m6k8YX0tibuwCcDSLFeu6dXqoLUkbC9XVTPkVSwHE= =kvMd -----END PGP SIGNATURE----- --gLMrnQYOa3AOROig-- --===============9117814018961418610== 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". --===============9117814018961418610==--