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 0914C44FAF for ; Sun, 15 Jan 2023 02:50:36 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 706E068BB5D; Sun, 15 Jan 2023 04:50:33 +0200 (EET) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 66D6568AF85 for ; Sun, 15 Jan 2023 04:50:27 +0200 (EET) Received: from 4eb231a0d1b36cedda43a2a005befe4d ([1.152.229.18]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 30F2oMgj004901 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Sun, 15 Jan 2023 02:50:25 GMT Date: Sun, 15 Jan 2023 13:50:18 +1100 From: Peter Ross To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20230111235432.2135-1-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> 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="===============7744711709461386925==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7744711709461386925== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rnwok7w46Z8d/bOj" Content-Disposition: inline --rnwok7w46Z8d/bOj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_fuzz= er-6743211456724992 >=20 > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/t= ree/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 *avct= x) > return 0; > } > =20 > -static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitCon= text *gb) > +static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitCont= ext *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 blo= ck[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 blo= ck[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 b= lock[64], GetBitContext *gb > } > } > block[0] +=3D 128 << 4; > + return 0; > } > =20 > static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFrame= *frame, > --=20 > 2.17.1 Hi Michael, The return value of tgq_decode() is not checked anywhere. Need to add something like: - tgq_decode_block(s, s->block[i], &gb); + if ((ret =3D tgq_decode_block(s, s->block[i], &gb)) < 0) + return ret; (From earlier attempt at fixing this: https://patchwork.ffmpeg.org/project/= ffmpeg/patch/1ab7c3994301a243fc64d59d6a08e3a2b364e411.1666774269.git.pross@= xvid.org/) -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --rnwok7w46Z8d/bOj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCY8Np6gAKCRBnYHnFrEDd a5u8AKDRL5IYtSsemeSbKOJp95rd00bV8ACfVHiEOZtmwSa8P1TkVNl57thz4GA= =MXD6 -----END PGP SIGNATURE----- --rnwok7w46Z8d/bOj-- --===============7744711709461386925== 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". --===============7744711709461386925==--