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 1901D40590 for ; Thu, 22 Dec 2022 23:26:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1140F68B720; Fri, 23 Dec 2022 01:26:08 +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 60922680677 for ; Fri, 23 Dec 2022 01:26:01 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 5D1E760004 for ; Thu, 22 Dec 2022 23:26:00 +0000 (UTC) Date: Fri, 23 Dec 2022 00:25:59 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221222232559.GE3806951@pb2> References: <20221112234401.24158-1-michael@niedermayer.cc> <20221112234401.24158-3-michael@niedermayer.cc> <41b2da576f810e3a0ef9439b2b496c98d583d887.camel@haerdin.se> MIME-Version: 1.0 In-Reply-To: <41b2da576f810e3a0ef9439b2b496c98d583d887.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="===============5646695745576637116==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5646695745576637116== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xLfTzkWEurH/gki3" Content-Disposition: inline --xLfTzkWEurH/gki3 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 ///< absol= ute 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_ess= ence_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 mx= f- > > >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]= =2Ethis_partition < p- > > >essence_offset) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 p->essence_l= ength =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->essence_l= ength =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. do you mean that pack_ofs could be used here ? (this is within 8 byte of this_partition) for the files i checked or something else ? but as pack_ofs is signed that either means dealing with potentially negati= ve or changing it to uint64_t or adding a new field and avio_tell() somewhere? thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is a danger to trust the dream we wish for rather than the science we have, -- Dr. Kenneth Brown --xLfTzkWEurH/gki3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY6TngAAKCRBhHseHBAsP q4lhAKCM/0HeJhA+wZKqT4FKhX5BUFKWvwCeN7rRydS7yHhlyRqF2vmJZvGeLGA= =Q/N6 -----END PGP SIGNATURE----- --xLfTzkWEurH/gki3-- --===============5646695745576637116== 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". --===============5646695745576637116==--