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 785D044EEF for ; Mon, 28 Nov 2022 21:33:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BF9D468B3C7; Mon, 28 Nov 2022 23:33:24 +0200 (EET) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5363468B01C for ; Mon, 28 Nov 2022 23:33:19 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 707FEC0002 for ; Mon, 28 Nov 2022 21:33:18 +0000 (UTC) Date: Mon, 28 Nov 2022 22:33:17 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221128213317.GN3806951@pb2> References: <20221127223435.8362-1-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 1/3] avcodec/mpeg12dec: Check input size 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="===============0350409615635977181==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============0350409615635977181== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0aF+6pWUK5w8WdCh" Content-Disposition: inline --0aF+6pWUK5w8WdCh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 28, 2022 at 12:47:32AM +0000, Kieran Kunhya wrote: > On Sun, 27 Nov 2022 at 22:34, Michael Niedermayer > wrote: >=20 > > Fixes: Timeout > > Fixes: > > 53599/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IPU_fuzzer-4950= 102511058944 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by > > : > > Michael Niedermayer > > --- > > libavcodec/mpeg12dec.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c > > index 914516bbd9..c93368e255 100644 > > --- a/libavcodec/mpeg12dec.c > > +++ b/libavcodec/mpeg12dec.c > > @@ -2969,6 +2969,9 @@ static int ipu_decode_frame(AVCodecContext *avctx, > > AVFrame *frame, > > GetBitContext *gb =3D &m->gb; > > int ret; > > > > + if (avpkt->size*8LL < (avctx->width+15)/16 * ((avctx->height+15)/1= 6) > > * 2 * 7) > > + return AVERROR_INVALIDDATA; > > + > > ret =3D ff_get_buffer(avctx, frame, 0); > > if (ret < 0) > > return ret; > > >=20 > Where does this AVPacket limitation come from? > Are you able to explain in a comment where these numbers come from? In > particular the "2 * 7". the ipu format has 2 bits minimum per MB except the first but theres more t= han 1 bit before so that can be simplified to 2 bits minimum per MB "header" each MB has 6 blocks blocks can be mpeg1 intra or mpeg2 intra these will at least contain one DC= VLC and the shortest is 2 bits. We could consider that the luma one is min 3 bu= t i didnt also we could consider teh AC EOB again i didnt 6 blocks 2 bits + 2 for MB is 7*2 (3*4 + 2*2 + 2) would consider the luma dc seperatly. we could add a 6*2 for the AC EOBs so 2 + 3*4 + 2*2 + 6*2 would be closer to the theoretic minimum. i will change the code to that and add a comment that this is the minimum MB size considering MB, DC and AC-EOB thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope --0aF+6pWUK5w8WdCh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY4UpFgAKCRBhHseHBAsP qxKqAJsFyy69ZdRulxPVdWWcYxpZaTJBIwCfZ32pcKhh3EANvE0TcNVhIw6et1w= =tWm8 -----END PGP SIGNATURE----- --0aF+6pWUK5w8WdCh-- --===============0350409615635977181== 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". --===============0350409615635977181==--