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 98C1747AAA for ; Sat, 30 Sep 2023 16:32:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0C64768CCC1; Sat, 30 Sep 2023 19:32:11 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B805968CA90 for ; Sat, 30 Sep 2023 19:32:09 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7FB64E0008 for ; Sat, 30 Sep 2023 16:32:08 +0000 (UTC) Date: Sat, 30 Sep 2023 18:32:07 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230930163207.GM3543730@pb2> References: <20230929232001.23197-1-michael@niedermayer.cc> <20230929232001.23197-4-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 4/6] avformat/cafdec: saturate start + size into 64bit 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="===============2560602734053022184==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2560602734053022184== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7trrzIZ+323l9a6P" Content-Disposition: inline --7trrzIZ+323l9a6P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 29, 2023 at 08:41:23PM -0300, James Almer wrote: > On 9/29/2023 8:19 PM, Michael Niedermayer wrote: > > Fixes: signed integer overflow: 64 + 9223372036854775803 cannot be repr= esented in type 'long long' > > Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-65368= 81135550464 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/cafdec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c > > index e92e3279fc6..0e50a3cfe68 100644 > > --- a/libavformat/cafdec.c > > +++ b/libavformat/cafdec.c > > @@ -435,7 +435,7 @@ static int read_packet(AVFormatContext *s, AVPacket= *pkt) > > /* don't read past end of data chunk */ > > if (caf->data_size > 0) { > > - left =3D (caf->data_start + caf->data_size) - avio_tell(pb); > > + left =3D av_sat_add64(caf->data_start, caf->data_size) - avio_= tell(pb); >=20 > avio_tell(pb) here is guaranteed to be bigger than caf->data_start, which= is > the offset where the DATA chunk starts, so the result of this calculation > will be <=3D INT64_MAX even if you don't saturate it and instead cast it = to > uint64_t. Nonetheless, if the DATA chunk ends at an offset that would not > fit in an int64_t, then we can't parse it to begin with due to AVIOContext > API limitations. >=20 > Maybe we should just abort in read_header() if data_start + data_size > > INT64_MAX, instead of pretending we can parse the file, invalid or not, by > saturating values. yes ill try that thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. --7trrzIZ+323l9a6P Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZRhNgwAKCRBhHseHBAsP q1SzAJ4xjX9IigOiT3nQnlpO0Acn2uaCNgCfTzTvrN0VLFcSWD2Gg7Q+eNQXkqY= =Wev6 -----END PGP SIGNATURE----- --7trrzIZ+323l9a6P-- --===============2560602734053022184== 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". --===============2560602734053022184==--