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 642C94524C for ; Sun, 15 Jan 2023 17:21:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 56FA068BCD5; Sun, 15 Jan 2023 19:21:31 +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 4A424680BF1 for ; Sun, 15 Jan 2023 19:21:23 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 1DBBF1BF204 for ; Sun, 15 Jan 2023 17:21:21 +0000 (UTC) Date: Sun, 15 Jan 2023 18:21:19 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230115172119.GU1949656@pb2> References: <20230111235432.2135-1-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 1/6] avcodec/eatgq: : Check index increments in tgq_decode_block() 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="===============8538200437538896555==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8538200437538896555== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TVVcQco/7vcH19KK" Content-Disposition: inline --TVVcQco/7vcH19KK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 15, 2023 at 01:50:18PM +1100, Peter Ross wrote: > On Thu, Jan 12, 2023 at 12:54:27AM +0100, Michael Niedermayer wrote: > > Fixes: out of array access > > Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGQ_fu= zzer-6743211456724992 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/eatgq.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > >=20 > > diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c > > index 89e9f20880..beb9f4d046 100644 > > --- a/libavcodec/eatgq.c > > +++ b/libavcodec/eatgq.c > > @@ -56,7 +56,7 @@ static av_cold int tgq_decode_init(AVCodecContext *av= ctx) > > return 0; > > } > > =20 > > -static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitC= ontext *gb) > > +static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitCo= ntext *gb) > > { > > const uint8_t *scantable =3D ff_zigzag_direct; > > int i, j, value; > > @@ -64,6 +64,8 @@ static void tgq_decode_block(TgqContext *s, int16_t b= lock[64], GetBitContext *gb > > for (i =3D 1; i < 64;) { > > switch (show_bits(gb, 3)) { > > case 4: > > + if (i >=3D 63) > > + return AVERROR_INVALIDDATA; > > block[scantable[i++]] =3D 0; > > case 0: > > block[scantable[i++]] =3D 0; > > @@ -73,6 +75,8 @@ static void tgq_decode_block(TgqContext *s, int16_t b= lock[64], GetBitContext *gb > > case 1: > > skip_bits(gb, 2); > > value =3D get_bits(gb, 6); > > + if (value > 64 - i) > > + return AVERROR_INVALIDDATA; > > for (j =3D 0; j < value; j++) > > block[scantable[i++]] =3D 0; > > break; > > @@ -100,6 +104,7 @@ static void tgq_decode_block(TgqContext *s, int16_t= block[64], GetBitContext *gb > > } > > } > > block[0] +=3D 128 << 4; > > + return 0; > > } > > =20 > > static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFra= me *frame, > > --=20 > > 2.17.1 >=20 > Hi Michael, >=20 > The return value of tgq_decode() is not checked anywhere. >=20 > Need to add something like: >=20 > - tgq_decode_block(s, s->block[i], &gb); > + if ((ret =3D tgq_decode_block(s, s->block[i], &gb)) < 0) > + return ret; will apply with this=20 thx >=20 > (From earlier attempt at fixing this: https://patchwork.ffmpeg.org/projec= t/ffmpeg/patch/1ab7c3994301a243fc64d59d6a08e3a2b364e411.1666774269.git.pros= s@xvid.org/) >=20 > -- Peter > (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. --TVVcQco/7vcH19KK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY8Q2DwAKCRBhHseHBAsP qyRfAJ9CLAVQXlZfwif97H6zQ1//VT5KDgCgkAt5fTYrDSGTXeW2BJRV68EHAGk= =Lnzr -----END PGP SIGNATURE----- --TVVcQco/7vcH19KK-- --===============8538200437538896555== 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". --===============8538200437538896555==--