From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7023E2194D387 for ; Wed, 17 Oct 2018 06:02:26 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 06:02:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,392,1534834800"; d="scan'208";a="79452281" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 17 Oct 2018 06:02:24 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 06:02:24 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 06:02:23 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.48]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Wed, 17 Oct 2018 21:02:21 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] MdeModulePkg BrotliDecompressLib: Add the checker to avoid array out of bound Thread-Index: AQHUZSHvZbn5UFoAsUGPu36te9XWz6UimnmAgAAAnwCAAM3S8A== Date: Wed, 17 Oct 2018 13:02:20 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E33CBD9@SHSMSX104.ccr.corp.intel.com> References: <1539674835-8860-1-git-send-email-liming.gao@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BC21992@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BC219AB@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BC219AB@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjI2ZWRlOTgtMzgwYy00YjI0LTkzNjEtNTNmOWRjNWJjMmRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMG1sZmNEMHFaOXFvOWZcL1U5U3NidHl6NDdpNWszUEN4d1V2bUFJa1gwQnp3NXVvNjM2dkhTalR4R3IxQ2FHK0wifQ== dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg BrotliDecompressLib: Add the checker to avoid array out of bound X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2018 13:02:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes. I will add those information. Thanks! > -----Original Message----- > From: Zeng, Star > Sent: Wednesday, October 17, 2018 4:45 PM > To: Gao, Liming ; edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: RE: [edk2] [Patch] MdeModulePkg BrotliDecompressLib: Add the che= cker to avoid array out of bound >=20 > Liming, >=20 > They are reported by some static analysis tool, right? > I think you add some information about it in the commit log. You can do t= hat when pushing the patch. >=20 > Thanks, > Star > -----Original Message----- > From: Zeng, Star > Sent: Wednesday, October 17, 2018 4:43 PM > To: Gao, Liming ; edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: RE: [edk2] [Patch] MdeModulePkg BrotliDecompressLib: Add the che= cker to avoid array out of bound >=20 > Reviewed-by: Star Zeng >=20 >=20 > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Li= ming Gao > Sent: Tuesday, October 16, 2018 3:27 PM > To: edk2-devel@lists.01.org > Subject: [edk2] [Patch] MdeModulePkg BrotliDecompressLib: Add the checker= to avoid array out of bound >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Liming Gao > --- > MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c | 13 +++++++= +----- > 1 file changed, 8 insertions(+), 5 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c > b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c > index fd42b3b..f3b3cb8 100644 > --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c > +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c > @@ -858,6 +858,7 @@ static BROTLI_INLINE uint32_t ReadBlockLength(const H= uffmanCode* table, > uint32_t code; > uint32_t nbits; > code =3D ReadSymbol(table, br); > + ASSERT (code < BROTLI_NUM_BLOCK_LEN_SYMBOLS); > nbits =3D kBlockLengthPrefixCode[code].nbits; /* nbits =3D=3D 2..24 *= / > return kBlockLengthPrefixCode[code].offset + BrotliReadBits(br, nbits)= ; } @@ -910,6 +911,7 @@ static BROTLI_NOINLINE void > InverseMoveToFrontTransform( > uint32_t upper_bound =3D state->mtf_upper_bound; > uint32_t* mtf =3D &state->mtf[1]; /* Make mtf[-1] addressable. */ > uint8_t* mtf_u8 =3D (uint8_t*)mtf; > + uint8_t* mtf_u8t =3D mtf_u8 - 1; > /* Load endian-aware constant. */ > const uint8_t b0123[4] =3D {0, 1, 2, 3}; > uint32_t pattern; > @@ -928,13 +930,13 @@ static BROTLI_NOINLINE void InverseMoveToFrontTrans= form( > for (i =3D 0; i < v_len; ++i) { > int index =3D v[i]; > uint8_t value =3D mtf_u8[index]; > - upper_bound |=3D v[i]; > + upper_bound |=3D (uint32_t) v[i]; > v[i] =3D value; > - mtf_u8[-1] =3D value; > - do { > + mtf_u8t[0] =3D value; > + while (index >=3D 0) { > + mtf_u8t[index + 1] =3D mtf_u8t[index]; > index--; > - mtf_u8[index + 1] =3D mtf_u8[index]; > - } while (index >=3D 0); > + } > } > /* Remember amount of elements to be reinitialized. */ > state->mtf_upper_bound =3D upper_bound >> 2; @@ -1566,6 +1568,7 @@ sta= tic BROTLI_INLINE BROTLI_BOOL > ReadCommandInternal( > BrotliBitReaderState memento; > if (!safe) { > cmd_code =3D ReadSymbol(s->htree_command, br); > + ASSERT (cmd_code < BROTLI_NUM_COMMAND_SYMBOLS); > } else { > BrotliBitReaderSaveState(br, &memento); > if (!SafeReadSymbol(s->htree_command, br, &cmd_code)) { > -- > 2.10.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel