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 C3ACF4035A for ; Sat, 19 Nov 2022 20:04:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7357E68B5E6; Sat, 19 Nov 2022 22:04:54 +0200 (EET) 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 38FA568B0A7 for ; Sat, 19 Nov 2022 22:04:48 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 2B488E0003 for ; Sat, 19 Nov 2022 20:04:46 +0000 (UTC) Date: Sat, 19 Nov 2022 21:04:45 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221119200445.GB710311@pb2> References: <20221118210918.3169-1-michael@niedermayer.cc> <20221118210918.3169-4-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 4/4] avcodec/vqcdec: Check for end of input in decode_vectors() 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="===============7199472155848786982==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7199472155848786982== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xXmbgvnjoT4axfJE" Content-Disposition: inline --xXmbgvnjoT4axfJE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 19, 2022 at 10:03:08AM +1100, Peter Ross wrote: > On Fri, Nov 18, 2022 at 10:09:18PM +0100, Michael Niedermayer wrote: > > Fixes: Timeout > > Fixes: 52695/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQC_fuzz= er-4882310386548736 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/vqcdec.c | 14 ++++++++++---- > > 1 file changed, 10 insertions(+), 4 deletions(-) > >=20 > > diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c > > index 5d1a03158c..18cd99462e 100644 > > --- a/libavcodec/vqcdec.c > > +++ b/libavcodec/vqcdec.c > > @@ -137,7 +137,7 @@ static void seed_codebooks(VqcContext * s, const in= t * seed) > > } > > } > > =20 > > -static void decode_vectors(VqcContext * s, const uint8_t * buf, int si= ze, int width, int height) > > +static int decode_vectors(VqcContext * s, const uint8_t * buf, int siz= e, int width, int height) > > { > > GetBitContext gb; > > uint8_t * vectors =3D s->vectors; > > @@ -155,9 +155,11 @@ static void decode_vectors(VqcContext * s, const u= int8_t * buf, int size, int wi > > *dst++ =3D get_bits(&gb, 8); > > =20 > > while (show_bits(&gb, 2) !=3D 2) { > > - > > if (dst >=3D vectors_end - 1) > > - return; > > + return 0; > > + > > + if (get_bits_left(&gb) < 4) > > + return AVERROR_INVALIDDATA; > > =20 > > if (!show_bits(&gb, 4)) { > > *dst++ =3D 0; > > @@ -182,6 +184,8 @@ static void decode_vectors(VqcContext * s, const ui= nt8_t * buf, int size, int wi > > skip_bits(&gb, 2); > > vectors +=3D 32; > > } > > + > > + return 0; > > } > > =20 > > static void load_coeffs(VqcContext * s, const uint8_t * v, int width, = int coeff_width) > > @@ -392,7 +396,9 @@ static int vqc_decode_frame(AVCodecContext *avctx, = AVFrame * rframe, > > avpriv_request_sample(avctx, "gamma=3D0x%x, contrast=3D0x%x\n"= , gamma, contrast); > > =20 > > seed_codebooks(s, seed); > > - decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->h= eight); > > + ret =3D decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, = avctx->height); > > + if (ret < 0) > > + return ret; > > decode_frame(s, avctx->width, avctx->height); >=20 > please apply will apply thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. --xXmbgvnjoT4axfJE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY3k21gAKCRBhHseHBAsP qyPgAJoCrp69i4hKIH1XpZPp4bXkMWtMOgCfd3KgzlL3mOLXPrb7FOVAOEA0P0Y= =64v6 -----END PGP SIGNATURE----- --xXmbgvnjoT4axfJE-- --===============7199472155848786982== 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". --===============7199472155848786982==--