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 66F9E44EBF for ; Sun, 27 Nov 2022 22:43:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B60068BBCC; Mon, 28 Nov 2022 00:43:51 +0200 (EET) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 783F568B9E7 for ; Mon, 28 Nov 2022 00:43:45 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id A51DB1BF207 for ; Sun, 27 Nov 2022 22:43:44 +0000 (UTC) Date: Sun, 27 Nov 2022 23:43:43 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221127224343.GF3806951@pb2> References: <20221122225652.1341-1-michael@niedermayer.cc> <20221125133846.GB3806951@pb2> <166938549275.4503.16165224502546034668@lain.khirnov.net> MIME-Version: 1.0 In-Reply-To: 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="===============2045631351334127113==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2045631351334127113== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="K/NRh952CO+2tg14" Content-Disposition: inline --K/NRh952CO+2tg14 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 26, 2022 at 10:42:30AM +1100, Peter Ross wrote: > 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_PI= CTOR_fuzzer-5458939919859712 > > > > >=20 > > > > > Found-by: continuous fuzzing process https://github.com/google/os= s-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 im= ages > > > 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 c= hanges > > > this limit > >=20 > > This should be written in a comment above the code then, otherwise all > > future readers will be completely clueless. >=20 > good idea. ok, patch looks good. ok will apply, i need to reword this comment a bit as the code changed already and the mid exit no longer exists thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad --K/NRh952CO+2tg14 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY4PoHwAKCRBhHseHBAsP q+zoAKCUvvq7hDJumIu0Q+71dGo+zV4DbQCeKfogG9xeVjGV8XKp5Pkz+kZtgdA= =Dr70 -----END PGP SIGNATURE----- --K/NRh952CO+2tg14-- --===============2045631351334127113== 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". --===============2045631351334127113==--