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 50A7A42846 for ; Tue, 4 Apr 2023 14:54:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 62A3F68B2D8; Tue, 4 Apr 2023 17:54:42 +0300 (EEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E10AF68A630 for ; Tue, 4 Apr 2023 17:54:35 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 0DDA3FF80B for ; Tue, 4 Apr 2023 14:54:34 +0000 (UTC) Date: Tue, 4 Apr 2023 16:54:34 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230404145434.GV1164690@pb2> References: <20230331152941.21879-1-pal@sandflow.com> <20230331152941.21879-2-pal@sandflow.com> <20230402221743.GQ1164690@pb2> <20230403142730.GS1164690@pb2> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v1 2/3] avcodec/jpeg2000dec: add support for HTJ2K block decoding 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="===============8831836521837147587==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8831836521837147587== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MLcyhLwX/7AHNQNx" Content-Disposition: inline --MLcyhLwX/7AHNQNx Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 03, 2023 at 07:20:05PM +0300, Caleb Etemesi wrote: > Hi >=20 > On Mon, Apr 3, 2023 at 5:28=E2=80=AFPM Michael Niedermayer > wrote: >=20 > > On Sun, Apr 02, 2023 at 03:21:08PM -0700, Pierre-Anthony Lemieux wrote: > > > On Sun, Apr 2, 2023 at 3:17=E2=80=AFPM Michael Niedermayer > > > wrote: > > > > > > > > On Fri, Mar 31, 2023 at 08:29:40AM -0700, pal@sandflow.com wrote: > > > > > From: caleb > > [...] > > > > [...] > > > > > +/** > > > > > + * Drops bits from lower bits in the bit buffer. buf contains the > > bit buffers. > > > > > + * nbits is the number of bits to remove. > > > > > + */ > > > > > +av_always_inline > > > > > +static void jpeg2000_bitbuf_drop_bits_lsb(StateVars *buf, uint8_t > > nbits) > > > > > +{ > > > > > + if (buf->bits_left < nbits) { > > > > > > > > > + av_log(NULL, AV_LOG_ERROR, "Invalid bit read of %d, bits= in > > buffer are %d\n", nbits, buf->bits_left); > > > > > + av_assert0(0); > > >=20 > This one is present to ensure for all test cases, we never overread bytes But can a crafted input stream trigger an assert failure ? If no then the assert is ok If yes then its not ok, i mean a "./ffmpeg -i /dev/random"=20 should not crash, it should provide the user with some error and teh code s= hould cleanly return not abort I simply do not know if theres a check or something somewhere that ensures this is ok and just a extra check (which is ok) >=20 >=20 > > > > > > > > > > > > [...] > > > > > +int > > > > > +ff_jpeg2000_decode_htj2k(const Jpeg2000DecoderContext *s, > > Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, > > > > > + int width, int height, int magp, uint8_t > > roi_shift) > > > > > +{ > > > > > + uint8_t p0 =3D 0; // Number of placeholder passes > > > > > + uint32_t Lcup; // Length of HT cleanup segment > > > > > + uint32_t Lref; // Length of Refinement segment > > > > > + uint32_t Scup; // HT cleanup segment suffix len= gth > > > > > + uint32_t Pcup; // HT cleanup segment prefix len= gth > > > > > + > > > > > + uint8_t S_blk; // Number of skipped magnitude > > bitplanes > > > > > + uint8_t pLSB; > > > > > + > > > > > + uint8_t *Dcup; // Byte of an HT cleanup segment > > > > > + uint8_t *Dref; // Byte of an HT refinement segm= ent > > > > > + > > > > > + int z_blk; // Number of ht coding pass > > > > > + > > > > > + uint8_t empty_passes; > > > > > + > > > > > + StateVars mag_sgn; // Magnitude and Sign > > > > > + StateVars mel; // Adaptive run-length coding > > > > > + StateVars vlc; // Variable Length coding > > > > > + StateVars sig_prop; // Significance propagation > > > > > + > > > > > + MelDecoderState mel_state; > > > > > + > > > > > + int ret; > > > > > + > > > > > + /* Temporary buffers */ > > > > > + int32_t *sample_buf; > > > > > + uint8_t *block_states; > > > > > + > > > > > + int32_t n, val; // Post-processing > > > > > + > > > > > + int32_t M_b =3D magp; > > > > > + av_assert0(width <=3D 1024U && height <=3D 1024U); > > > > > + av_assert0(width * height <=3D 4096); > > > > > + av_assert0(width * height > 0); > > > > > > > > Has this decoder been tested with some fuzzer ? > > > > > > Yes. > > > > ok > > > > > > > > > > > I see a bunch of asserts in it and i dont immedeatly see what would > > prevent them from > > > > triggering > > > > > maybe you can add comments to the asserts that explain why these are > > > guranteed to be true thx > > > > > These ones are to check code block constraints, the jpeg2000 spec limits > code blocks to be between 2^2 and 2^10. The spec isnt that important here. The important part is that our code chec= ks this, so no input can trigger the asserts. I think we do check this, so i think the asserts are ok thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. --MLcyhLwX/7AHNQNx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZCw6JQAKCRBhHseHBAsP qwJMAJwPm6XyAIfoXtlOiX8+Gf/ZWOTBgwCdGD89QkVoAzUq0FyTPkQNlmFE4pI= =3mXp -----END PGP SIGNATURE----- --MLcyhLwX/7AHNQNx-- --===============8831836521837147587== 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". --===============8831836521837147587==--