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 D725944D2B for ; Fri, 18 Nov 2022 23:03:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0523968B7DA; Sat, 19 Nov 2022 01:03:32 +0200 (EET) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 986F468B6E2 for ; Sat, 19 Nov 2022 01:03:24 +0200 (EET) Received: from 4eb231a0d1b36cedda43a2a005befe4d ([1.152.242.131]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 2AIN3DHP015128 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Fri, 18 Nov 2022 23:03:17 GMT Date: Sat, 19 Nov 2022 10:03:08 +1100 From: Peter Ross To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20221118210918.3169-1-michael@niedermayer.cc> <20221118210918.3169-4-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: <20221118210918.3169-4-michael@niedermayer.cc> 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="===============5419342864605135666==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5419342864605135666== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DVcCsNqYg5bcusND" Content-Disposition: inline --DVcCsNqYg5bcusND Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_fuzzer= -4882310386548736 >=20 > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/t= ree/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 int = * seed) > } > } > =20 > -static void decode_vectors(VqcContext * s, const uint8_t * buf, int size= , int width, int height) > +static int decode_vectors(VqcContext * s, const uint8_t * buf, int size,= int width, int height) > { > GetBitContext gb; > uint8_t * vectors =3D s->vectors; > @@ -155,9 +155,11 @@ static void decode_vectors(VqcContext * s, const uin= t8_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 uint= 8_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, in= t coeff_width) > @@ -392,7 +396,9 @@ static int vqc_decode_frame(AVCodecContext *avctx, AV= Frame * 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->hei= ght); > + ret =3D decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, av= ctx->height); > + if (ret < 0) > + return ret; > decode_frame(s, avctx->width, avctx->height); please apply -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --DVcCsNqYg5bcusND Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCY3gPKAAKCRBnYHnFrEDd a4WyAKCbHhkQQiBhi3dftzLpf5cCZ4L42ACfQSchCNxyG6I10cg92UOzFJAKl1U= =y+cj -----END PGP SIGNATURE----- --DVcCsNqYg5bcusND-- --===============5419342864605135666== 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". --===============5419342864605135666==--