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 C7C0444D94 for ; Fri, 23 Dec 2022 21:22:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC87A68BB81; Fri, 23 Dec 2022 23:22:16 +0200 (EET) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DDA3468B9F2 for ; Fri, 23 Dec 2022 23:22:09 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 2526F60004 for ; Fri, 23 Dec 2022 21:22:08 +0000 (UTC) Date: Fri, 23 Dec 2022 22:22:08 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221223212208.GI3806951@pb2> References: <20221112234401.24158-1-michael@niedermayer.cc> <20221112234401.24158-3-michael@niedermayer.cc> <41b2da576f810e3a0ef9439b2b496c98d583d887.camel@haerdin.se> <20221222232559.GE3806951@pb2> <22aa81a6cbb26b250dec7a5d44dc275c6e95f801.camel@haerdin.se> MIME-Version: 1.0 In-Reply-To: <22aa81a6cbb26b250dec7a5d44dc275c6e95f801.camel@haerdin.se> Subject: Re: [FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Reduce overflows in essence_length computation 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="===============7223587380208507414==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7223587380208507414== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2W4wSx0jmTCcLO7w" Content-Disposition: inline --2W4wSx0jmTCcLO7w Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 23, 2022 at 12:47:02PM +0100, Tomas H=E4rdin wrote: > fre 2022-12-23 klockan 00:25 +0100 skrev Michael Niedermayer: > > On Wed, Nov 16, 2022 at 12:49:10PM +0100, Tomas H=E4rdin wrote: > > > s=F6n 2022-11-13 klockan 00:44 +0100 skrev Michael Niedermayer: > > > > Fixes: signed integer overflow: -3741319169 - 9223372036823449370 > > > > cannot be represented in type 'long' > > > > Fixes: 51896/clusterfuzz-testcase-minimized- > > > > ffmpeg_dem_MXF_fuzzer- > > > > 513039428681728 > > > >=20 > > > > Found-by: continuous fuzzing process=20 > > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > > > Signed-off-by: Michael Niedermayer > > > > --- > > > > =A0libavformat/mxfdec.c | 10 +++++++--- > > > > =A01 file changed, 7 insertions(+), 3 deletions(-) > > > >=20 > > > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > > > > index e6118e141d..42109cb43a 100644 > > > > --- a/libavformat/mxfdec.c > > > > +++ b/libavformat/mxfdec.c > > > > @@ -100,7 +100,7 @@ typedef struct MXFPartition { > > > > =A0=A0=A0=A0 uint64_t previous_partition; > > > > =A0=A0=A0=A0 int index_sid; > > > > =A0=A0=A0=A0 int body_sid; > > > > -=A0=A0=A0 int64_t this_partition; > > > > +=A0=A0=A0 uint64_t this_partition; > > > > =A0=A0=A0=A0 int64_t essence_offset;=A0=A0=A0=A0=A0=A0=A0=A0 ///< a= bsolute offset of > > > > essence > > > > =A0=A0=A0=A0 int64_t essence_length; > > > > =A0=A0=A0=A0 int32_t kag_size; > > > > @@ -3519,8 +3519,12 @@ static void > > > > mxf_compute_essence_containers(AVFormatContext *s) > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 p->essence_offset =3D p->first= _essence_klv.offset; > > > > =A0 > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* essence container spans to = the next partition */ > > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (x < mxf->partitions_count - = 1) > > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 p->essence_length = =3D mxf- > > > > > partitions[x+1].this_partition - p->essence_offset; > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (x < mxf->partitions_count - = 1) { > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (mxf->partitions[= x+1].this_partition < p- > > > > > essence_offset) { > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 p->essen= ce_length =3D -1; > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } else > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 p->essen= ce_length =3D mxf- > > > > > partitions[x+1].this_partition - p->essence_offset; > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > > >=20 > > > A better solution might be to record the actual offset of the > > > partitions rather than relying on ThisPartition. Then we can > > > guarantee > > > that they are strictly increasing. > >=20 > > do you mean that pack_ofs could be used here ? >=20 > this_partition should be =3D=3D pack_ofs - run_in. I think we can just nu= ke > this_partition in the struct and use pack_ofs - run_in everywhere. Emit > a warning or bail out if any partition does not obey this contraint, > since such files have likely been written by bad muxers. ill post a patch doing that thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Elect your leaders based on what they did after the last election, not based on what they say before an election. --2W4wSx0jmTCcLO7w Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY6Yb+QAKCRBhHseHBAsP q80CAJ9Ylj4bgAf5vnpgZPEV7mmaVged9gCeI07l6EDrI8QnpjAcc7zlP3uVqBs= =eusR -----END PGP SIGNATURE----- --2W4wSx0jmTCcLO7w-- --===============7223587380208507414== 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". --===============7223587380208507414==--