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.65; helo=mga03.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 5933E21159CBC for ; Thu, 27 Sep 2018 19:39:11 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 19:39:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,313,1534834800"; d="scan'208";a="87405467" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 27 Sep 2018 19:33:09 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 19:32:48 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 19:32:48 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.245]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.27]) with mapi id 14.03.0319.002; Fri, 28 Sep 2018 10:32:46 +0800 From: "Fu, Siyuan" To: "Li, Songpeng" , "edk2-devel@lists.01.org" CC: "Wu, Jiaxin" Thread-Topic: [edk2] [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow. Thread-Index: AQHUVs68/QyIwr2hHUSANySp6tb1kqUE+W5w Date: Fri, 28 Sep 2018 02:32:45 +0000 Message-ID: References: <20180928015706.32068-1-songpeng.li@intel.com> <20180928015706.32068-3-songpeng.li@intel.com> In-Reply-To: <20180928015706.32068-3-songpeng.li@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGFkZmUxYzQtN2ExMC00Y2MzLTk2NTEtMDczYjUwNzI2ZGFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRUljTERnXC9LNlVxUGtFdXNiQitEamNoVkM3YXVpOHQrSkZreFJUNXhIQ24wa2lqXC9hQmRmWTZYWUJuSDdNMFdmIn0= 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 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory access overflow. 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: Fri, 28 Sep 2018 02:39:11 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Songpeng Li > Sent: Friday, September 28, 2018 9:57 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan ; Wu, Jiaxin > Subject: [edk2] [PATCH 2/2] NetworkPkg/HttpUtilitiesDxe: fix read memory > access overflow. >=20 > The input param String of AsciiStrStr() requires a pointer to > Null-terminated string, however in HttpUtilitiesParse(), > the Buffersize before AllocateZeroPool() is equal to the size > of TCP header, after the CopyMem(), it might not end with > Null-terminator. It might cause memory access overflow. >=20 > Cc: Fu Siyuan > Cc: Wu Jiaxin > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1204 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Songpeng Li > --- > NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) >=20 > diff --git a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c > b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c > index a9a1c7c586..b0e3e7f081 100644 > --- a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c > +++ b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c > @@ -298,6 +298,7 @@ HttpUtilitiesParse ( > CHAR8 *FieldName; > CHAR8 *FieldValue; > UINTN Index; > + UINTN HttpBufferSize; >=20 > Status =3D EFI_SUCCESS; > TempHttpMessage =3D NULL; > @@ -311,12 +312,17 @@ HttpUtilitiesParse ( > return EFI_INVALID_PARAMETER; > } >=20 > - TempHttpMessage =3D AllocateZeroPool (HttpMessageSize); > + // > + // Append the http response string along with a Null-terminator. > + // > + HttpBufferSize =3D HttpMessageSize + 1; > + TempHttpMessage =3D AllocatePool (HttpBufferSize); > if (TempHttpMessage =3D=3D NULL) { > return EFI_OUT_OF_RESOURCES; > } >=20 > CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize); > + *(TempHttpMessage + HttpMessageSize) =3D '\0'; >=20 > // > // Get header number > -- > 2.18.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel