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 91D6D4105E for ; Tue, 15 Mar 2022 12:48:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3693168B1B5; Tue, 15 Mar 2022 14:48:26 +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 CA88A68AEAF for ; Tue, 15 Mar 2022 14:48:19 +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 A641BFF80A for ; Tue, 15 Mar 2022 12:48:18 +0000 (UTC) Date: Tue, 15 Mar 2022 13:48:17 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220315124817.GD2829255@pb2> References: <20220312235227.19626-1-michael@niedermayer.cc> <20220312235227.19626-3-michael@niedermayer.cc> <1e687354-29fa-6c18-2850-c1fe7da6bd42@passwd.hu> <20220314135819.GW2829255@pb2> <7e83992a-db22-601f-782b-96c2cfe54bd4@passwd.hu> MIME-Version: 1.0 In-Reply-To: <7e83992a-db22-601f-782b-96c2cfe54bd4@passwd.hu> Subject: Re: [FFmpeg-devel] [PATCH 3/4] avformat/mxfdec: Check for avio_read() failure 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="===============2631171911030275101==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2631171911030275101== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PAWMR2MdzdiWVDP+" Content-Disposition: inline --PAWMR2MdzdiWVDP+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 14, 2022 at 06:08:32PM +0100, Marton Balint wrote: >=20 >=20 > On Mon, 14 Mar 2022, Michael Niedermayer wrote: >=20 > > On Sun, Mar 13, 2022 at 04:52:25PM +0100, Marton Balint wrote: > > >=20 > > >=20 > > > On Sun, 13 Mar 2022, Michael Niedermayer wrote: > > >=20 > > > > Signed-off-by: Michael Niedermayer > > > > --- > > > > libavformat/mxfdec.c | 8 +++++++- > > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > >=20 > > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > > > > index d7cdd22c8a..828fc0f9f1 100644 > > > > --- a/libavformat/mxfdec.c > > > > +++ b/libavformat/mxfdec.c > > > > @@ -932,6 +932,7 @@ static int mxf_read_cryptographic_context(void = *arg, AVIOContext *pb, int tag, i > > > >=20 > > > > static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, i= nt *count) > > > > { > > > > + int64_t ret; > > > > unsigned c =3D avio_rb32(pb); > > > >=20 > > > > //avio_read() used int > > > > @@ -946,7 +947,12 @@ static int mxf_read_strong_ref_array(AVIOConte= xt *pb, UID **refs, int *count) > > > > return AVERROR(ENOMEM); > > > > } > > > > avio_skip(pb, 4); /* useless size of objects, always 16 accordi= ng to specs */ > > > > - avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); > > > > + ret =3D avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); > > > > + if (ret !=3D *count * sizeof(UID)) { > > > > + *count =3D ret < 0 ? 0 : ret / sizeof(UID); > > >=20 > >=20 > > > I suggest you hard fail if the read count is not the expected, do not > > > silently ignore corrupt file. > > >=20 > > > Regards, > > > Marton > > >=20 > > > > + return ret < 0 ? ret : AVERROR_INVALIDDATA; > >=20 > > Does it not hard fail here ? >=20 > Yeah, it does, sorry. This extra count calculation confused me... I'd just > probably set it to 0 in case of a partial read, same as in case of an err= or, > but fine either way I guess. i wanted to set the count to be most correct value. So if someone was debuging this and tried to just not fail it would already have a useable value in count. thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle --PAWMR2MdzdiWVDP+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYjCLDgAKCRBhHseHBAsP q4TIAJkBzqgwmleLtA4ffLzq4dFPnCkLZgCbBODM1NHWlCdo9NgoysenKBrnQYU= =XOWU -----END PGP SIGNATURE----- --PAWMR2MdzdiWVDP+-- --===============2631171911030275101== 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". --===============2631171911030275101==--