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 EEC2E4068E for ; Wed, 22 Dec 2021 13:13:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08FAF68B06D; Wed, 22 Dec 2021 15:13:52 +0200 (EET) Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F9AE68A920 for ; Wed, 22 Dec 2021 15:13:46 +0200 (EET) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 1BMDDjZQ022720 for ; Wed, 22 Dec 2021 14:13:45 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 1B4E2E1DC8; Wed, 22 Dec 2021 14:13:45 +0100 (CET) Date: Wed, 22 Dec 2021 14:13:45 +0100 From: Nicolas George To: FFmpeg development discussions and patches Message-ID: References: <20211222124728.7300-1-ffmpeg@gyani.pro> MIME-Version: 1.0 In-Reply-To: <20211222124728.7300-1-ffmpeg@gyani.pro> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Wed, 22 Dec 2021 14:13:45 +0100 (CET) Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/mov: add validate_box_size 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="===============1812044713306990208==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1812044713306990208== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vHGjxESrD13nY6eD" Content-Disposition: inline --vHGjxESrD13nY6eD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Gyan Doshi (12021-12-22): > Helper function to check if stored box size is correct and looks > to be fully available. > --- > libavformat/mov.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) >=20 > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 2aed6e80ef..7de95b7ab0 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -80,6 +80,40 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f= ); > static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_co= unt, unsigned int* allocated_size, > int count, int duration); > =20 > +/** Check if the box size meets the requirements passed in limit and co= nstraint_type. > + * If input avio_size is valid, it checks if box size appears to be av= ailable. > + * > + * constraint_type may be > + * 0 if the box size has to be exactly equal to limit > + * -1 if the box size has to be at most limit > + * 1 if the box size has to be at least limit > + * > + * Returns 0 if size meets requirements. > + */ > +static int validate_box_size(MOVContext *c, MOVAtom atom, AVIOContext *p= b, > + int64_t pos, int64_t limit, int constraint_= type) > +{ > + int size_fit; > + int64_t input_size =3D avio_size(pb); > + > + if (input_size > 0 && > + input_size - pos < atom.size) { > + av_log(c->fc, AV_LOG_ERROR, "Box %s is truncated\n", av_fourcc2s= tr(atom.type)); > + return AVERROR_INVALIDDATA; > + } > + > + if (FFABS(constraint_type) > 1) > + return AVERROR_BUG; av_assert() whould have been the right choice here. > + > + switch(constraint_type) { > + case 0: size_fit =3D atom.size =3D=3D limit; break; > + case -1: size_fit =3D atom.size <=3D limit; break; > + case 1: size_fit =3D atom.size >=3D limit; break; This code is unused, AFAICS. Not a good idea. > + } > + > + return !size_fit; > +} > + > static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext = *pb, > unsigned len, const char *k= ey) > { I think the changes belong in a single patch. Regards, --=20 Nicolas George --vHGjxESrD13nY6eD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6ooRQGBoNzw0KnwPcZVLI8pNxgwFAmHDJIcACgkQcZVLI8pN xgyEdxAAjm0ljLZIJtnDWxkkNh3xriTBQjNFdx8POEw208rrK5d/ilzG3k9g0KNg +VaaTSys3/pxzyp9bBW1Lfd8uMFV4mBf5nFETTOSxZwHsN+VMsYNjzSNxnTiSBaU FfFOFpWMEUgA4LAlZKd5i3Mmx+PjVaD6+naH0JqI0VQ3tkbCT8XWKD53FqrUbF/l 72l436ZeQN6w9EWOS0lzm5XamKBGmxcoYk3lFTJPbZHF1JuURFcRvU6EtHI0OsOT xEvTCZYoiLcM5i36xLSgQ6XlKrbzI4NJmEIGM7aexeCB/YD41wbRnghvEn5xlspG zNfmM2QmLsTdUmE/ylzXDHoYBNvMgoS9ixYUlC8gE7oHIzc9gaAIraF75APM92fq teZ7smC3J7DGWndOQ+U7drRhyq+PMQSVA1dpmss/0de59och+ngnl+lfr7weZiUx 0F9vl9W528Ay+acQYTUk5orf8JuVdY3fnooNlge9LZ9Te3Ol1zJSLw2aW3eUP88G l3R4ki19/A/1onc13P0tDSRoOtYppHYr22gosPxFctqGdLDuADUyeFMyl13NVOP/ 9CVSHU94be+5N0r8uNq0GNp1UrD3hxq57cm3NZVPGUZ9wJQWDcoHbe7cgpeoAn9q Ji3mDlw8Scq6CO8fArTCwm8moJGMRFfT30K53/vM14wSut8Fx9Q= =sMHM -----END PGP SIGNATURE----- --vHGjxESrD13nY6eD-- --===============1812044713306990208== 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". --===============1812044713306990208==--