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 5DB7444E38 for ; Fri, 25 Nov 2022 23:42:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE54468B7DB; Sat, 26 Nov 2022 01:42:50 +0200 (EET) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3577068B48E for ; Sat, 26 Nov 2022 01:42:44 +0200 (EET) Received: from 4eb231a0d1b36cedda43a2a005befe4d ([1.136.212.171]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 2APNgYGl018520 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Fri, 25 Nov 2022 23:42:39 GMT Date: Sat, 26 Nov 2022 10:42:30 +1100 From: Peter Ross To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20221122225652.1341-1-michael@niedermayer.cc> <20221125133846.GB3806951@pb2> <166938549275.4503.16165224502546034668@lain.khirnov.net> MIME-Version: 1.0 In-Reply-To: <166938549275.4503.16165224502546034668@lain.khirnov.net> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/pictordec: Check that the image fits in the input 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="===============5676639397216843512==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5676639397216843512== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YJmf4Jq3EzQBX2cr" Content-Disposition: inline --YJmf4Jq3EzQBX2cr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 25, 2022 at 03:11:32PM +0100, Anton Khirnov wrote: > Quoting Michael Niedermayer (2022-11-25 14:38:46) > > t On Fri, Nov 25, 2022 at 05:45:29PM +1100, Peter Ross wrote: > > > On Tue, Nov 22, 2022 at 11:56:51PM +0100, Michael Niedermayer wrote: > > > > Fixes: Timeout > > > > Fixes: 53438/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICT= OR_fuzzer-5458939919859712 > > > >=20 > > > > Found-by: continuous fuzzing process https://github.com/google/oss-= fuzz/tree/master/projects/ffmpe > > > > Signed-off-by: Michael Niedermayer > > > > --- > > > > libavcodec/pictordec.c | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > >=20 > > > > diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c > > > > index 71bad40a0a..09229b94fd 100644 > > > > --- a/libavcodec/pictordec.c > > > > +++ b/libavcodec/pictordec.c > > > > @@ -162,6 +162,9 @@ static int decode_frame(AVCodecContext *avctx, = AVFrame *frame, > > > > =20 > > > > if (av_image_check_size(s->width, s->height, 0, avctx) < 0) > > > > return -1; > > > > + if (bytestream2_get_bytes_left(&s->g) < s->width * s->height /= 65536 * 5) > > > > + return AVERROR_INVALIDDATA; > > >=20 > > > how did you arrive at this formula? > >=20 > > There are 2 coding modes, RLE and RAW > > I assume usable raw images will need around W*H and thus more than RLE > > RLE codes the most compressed runs by > > 1 byte for val (=3Dmarker) > > 1 byte run (=3D0) > > 2 bytes run=20 > > 1 byte val > > thats 5 bytes and the maximum run we can code is 65535 > >=20 > > The RLE decoder loop exits before applying the last RLE run and then > > there is a seperate piece of code after it that fills the last color to > > the end. Iam not sure why its done like that way but if i remove that > > mid exit the seperate code piece becomes unused for all images i have > > so it seems all RLE images are always fully coded with no special case > > at the end. > > Based on this iam guesing that my formula is correct for undamaged imag= es > > but of course i could find one tomorrow that exploits the special end > > handling and breaks this formula > > and of course its very possible that i missed some other thing that cha= nges > > this limit >=20 > This should be written in a comment above the code then, otherwise all > future readers will be completely clueless. good idea. ok, patch looks good. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --YJmf4Jq3EzQBX2cr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCY4FS4gAKCRBnYHnFrEDd azIfAKDMOGt3EduAqSehgAuJp3Rd5ubcwACeI0FnWVeJOrJLf2+Qj+gXoki0zlw= =a6dB -----END PGP SIGNATURE----- --YJmf4Jq3EzQBX2cr-- --===============5676639397216843512== 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". --===============5676639397216843512==--