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 5633443735 for ; Wed, 26 Oct 2022 08:51:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E67A968BB33; Wed, 26 Oct 2022 11:51:44 +0300 (EEST) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 611C968B61A for ; Wed, 26 Oct 2022 11:51:38 +0300 (EEST) Received: from bdf1c2b75a6ee6b82f766cd557e6dab7 ([1.145.236.2]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 29Q8pT6d025534 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Wed, 26 Oct 2022 08:51:33 GMT Date: Wed, 26 Oct 2022 19:51:26 +1100 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: <1ab7c3994301a243fc64d59d6a08e3a2b364e411.1666774269.git.pross@xvid.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/eatgq: prevent out of bounds memory access and endless loop 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="===============5392639775780640172==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5392639775780640172== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qUKqx3QFkEz04c5M" Content-Disposition: inline --qUKqx3QFkEz04c5M Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable --- libavcodec/eatgq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 89e9f20880..fdda8286ef 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -56,7 +56,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx) return 0; } =20 -static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitConte= xt *gb) +static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContex= t *gb) { const uint8_t *scantable =3D ff_zigzag_direct; int i, j, value; @@ -73,7 +73,9 @@ static void tgq_decode_block(TgqContext *s, int16_t block= [64], GetBitContext *gb case 1: skip_bits(gb, 2); value =3D get_bits(gb, 6); - for (j =3D 0; j < value; j++) + if (!value) + return AVERROR_INVALIDDATA; + for (j =3D 0; j < value && i < 64; j++) block[scantable[i++]] =3D 0; break; case 6: @@ -100,6 +102,7 @@ static void tgq_decode_block(TgqContext *s, int16_t blo= ck[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, @@ -161,7 +164,8 @@ static int tgq_decode_mb(TgqContext *s, GetByteContext = *gbyte, return ret; =20 for (i =3D 0; i < 6; i++) - tgq_decode_block(s, s->block[i], &gb); + if ((ret =3D tgq_decode_block(s, s->block[i], &gb)) < 0) + return ret; tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y); bytestream2_skip(gbyte, mode); } else { --=20 2.35.1 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --qUKqx3QFkEz04c5M Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCY1j1DgAKCRBnYHnFrEDd a6jjAKCcYxUzoJF9wMMBgyczrFh/52hTdQCfSdvlo8SZggg1f/G1jzcSwTQxQUA= =EPI0 -----END PGP SIGNATURE----- --qUKqx3QFkEz04c5M-- --===============5392639775780640172== 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". --===============5392639775780640172==--