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.20; helo=mga02.intel.com; envelope-from=ray.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 14B18211B76CF for ; Mon, 28 Jan 2019 19:45:04 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 19:45:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,535,1539673200"; d="scan'208";a="133959557" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 28 Jan 2019 19:45:04 -0800 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:45:03 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:45:03 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.110]) with mapi id 14.03.0415.000; Tue, 29 Jan 2019 11:45:01 +0800 From: "Ni, Ray" 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: AQHUkchEv2XxUVSJ0EyidYNkcs5sAaXF5j2g Date: Tue, 29 Jan 2019 03:41:53 +0000 Deferred-Delivery: Tue, 29 Jan 2019 03:45:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BFF751C@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, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 03:45:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni > -----Original Message----- > From: edk2-devel On Behalf Of Shenglei > 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 > step >=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/Library/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, EITHER 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/MdePkg/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_PATH_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