From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 CF38A211B76CF for ; Mon, 28 Jan 2019 17:29:24 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 17:29:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,535,1539673200"; d="scan'208";a="315659230" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 28 Jan 2019 17:29:23 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 17:29:23 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 17:29:23 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.172]) with mapi id 14.03.0415.000; Tue, 29 Jan 2019 09:29:21 +0800 From: "Gao, Liming" To: "Zhang, Shenglei" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Gao, Liming" Thread-Topic: [edk2] [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step Thread-Index: AQHUkcg8T+nGYvCIcU+9uZw2IpEQGqXE5Nmg Date: Tue, 29 Jan 2019 01:29:20 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3D190B@SHSMSX104.ccr.corp.intel.com> References: <20181212031011.20996-1-shenglei.zhang@intel.com> <20181212031011.20996-3-shenglei.zhang@intel.com> In-Reply-To: <20181212031011.20996-3-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTQyYjlmZjktMWUwNS00NGViLWE3ZTAtODAxYjA2OWRiYTRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTENzNzBuYjFcL0pVdEN0cEV6OTZibEVWcytUVHd5NTFHV1l4RmZ5VmlQdGlQNkw1WEN0bnYxYVVGS0p1NFo3eDYifQ== 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 v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step 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: Tue, 29 Jan 2019 01:29:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Shenglei: The patch is good. Reviewed-by: Liming Gao =20 Besides, this patch is from MS Mu project. Please keep original patch aut= hor. You don't need to send this patch again.=20 Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Sh= englei Zhang > Sent: Wednesday, December 12, 2018 11:10 AM > To: edk2-devel@lists.01.org > Cc: Kinney, Michael D ; Gao, Liming > Subject: [edk2] [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking s= tep >=20 > Add a checking step in DevicePathUtilities.c to verify the DevicePath. > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1372 >=20 > v2: Remove ASSERT() and the redundant checking step. > Update related description in DevicePathLib.h >=20 > Cc: Liming Gao > Cc: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Shenglei Zhang > --- > MdePkg/Include/Library/DevicePathLib.h | 2 +- > .../UefiDevicePathLib/DevicePathUtilities.c | 14 ++++++-------- > 2 files changed, 7 insertions(+), 9 deletions(-) >=20 > diff --git a/MdePkg/Include/Library/DevicePathLib.h b/MdePkg/Include/Libr= ary/DevicePathLib.h > index 959299704a..717d4db42f 100644 > --- a/MdePkg/Include/Library/DevicePathLib.h > +++ b/MdePkg/Include/Library/DevicePathLib.h > @@ -22,7 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. >=20 > /** > Determine whether a given device path is valid. > - If DevicePath is NULL, then ASSERT(). > + If DevicePath is NULL or the size is not suitable, then return false. >=20 > @param DevicePath A pointer to a device path data structure. > @param MaxSize The maximum size of the device path data structure= . > diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/Mde= Pkg/Library/UefiDevicePathLib/DevicePathUtilities.c > index 665e5a4adc..05f82c1313 100644 > --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c > +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c > @@ -59,19 +59,17 @@ IsDevicePathValid ( > UINTN Size; > UINTN NodeLength; >=20 > - ASSERT (DevicePath !=3D NULL); > - > - if (MaxSize =3D=3D 0) { > - MaxSize =3D MAX_UINTN; > - } > - > // > - // Validate the input size big enough to touch the first node. > + //Validate the input whether exists and its size big enough to touch t= he first node > // > - if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { > + if (DevicePath =3D=3D NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PAT= H_LENGTH)) { > return FALSE; > } >=20 > + if (MaxSize =3D=3D 0) { > + MaxSize =3D MAX_UINTN; > + } > + > for (Count =3D 0, Size =3D 0; !IsDevicePathEnd (DevicePath); DevicePat= h =3D NextDevicePathNode (DevicePath)) { > NodeLength =3D DevicePathNodeLength (DevicePath); > if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { > -- > 2.18.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel