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.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 822A720971733 for ; Mon, 28 Jan 2019 19:08:09 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 19:08:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,535,1539673200"; d="scan'208";a="118230877" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 28 Jan 2019 19:08:08 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:08:07 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:08:06 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.36]) with mapi id 14.03.0415.000; Tue, 29 Jan 2019 11:08:04 +0800 From: "Gao, Liming" To: "Zhang, Shenglei" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Thread-Index: AQHUkcg5XrHNDYnuN0iAMjv2iqhSiqXF3BxQ Date: Tue, 29 Jan 2019 03:08:04 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3D1B4B@SHSMSX104.ccr.corp.intel.com> References: <20181212031011.20996-1-shenglei.zhang@intel.com> <20181212031011.20996-2-shenglei.zhang@intel.com> In-Reply-To: <20181212031011.20996-2-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGYyNWNjMmMtYjNiMC00MmE1LWJiMzItZmE5ZjUwOWE2NzViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSnhmNFRYRnRwc1JGczc5YnN3RVNxNWNsclNtUGVpV3ZLelprM0hSTFBuQzFEWldDM1NtNHA4azg3SnRKaVh0NyJ9 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] BaseTools/DevicePath: 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:08:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----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: Gao, Liming > Subject: [edk2] [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step >=20 > Add a checking step in DevicePathUtilities.c > to verify DevicePath. > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1372 >=20 > v2: Remove ASSERT() and the redundant checking step. > Update related description. >=20 > Cc: Bob Feng > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Shenglei Zhang > --- > .../Source/C/DevicePath/DevicePathUtilities.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) >=20 > diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTo= ols/Source/C/DevicePath/DevicePathUtilities.c > index f8a41ff97d..e0399cfea7 100644 > --- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c > +++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c > @@ -36,12 +36,13 @@ CONST EFI_DEVICE_PATH_PROTOCOL mUefiDevicePathLibEnd= DevicePath =3D { >=20 > /** > Determine whether a given device path is valid. > - If DevicePath is NULL, then ASSERT(). >=20 > @param DevicePath A pointer to a device path data structure. > @param MaxSize The maximum size of the device path data structure= . >=20 > @retval TRUE DevicePath is valid. > + @retval FALSE DevicePath is NULL. > + @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOC= OL). > @retval FALSE The length of any node node in the DevicePath is l= ess > than sizeof (EFI_DEVICE_PATH_PROTOCOL). > @retval FALSE If MaxSize is not zero, the size of the DevicePath > @@ -59,17 +60,15 @@ IsDevicePathValid ( > UINTN Size; > UINTN NodeLength; >=20 > - ASSERT (DevicePath !=3D NULL); > + // > + // Validate the input whether exists and its size big enough to touch= the first node > + // > + if (DevicePath =3D=3D NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PAT= H_LENGTH)) { > + return FALSE; > + } >=20 > if (MaxSize =3D=3D 0) { > MaxSize =3D MAX_UINT32; > - } > - > - // > - // Validate the input size big enough to touch the first node. > - // > - if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { > - return FALSE; > } >=20 > for (Count =3D 0, Size =3D 0; !IsDevicePathEnd (DevicePath); DevicePat= h =3D NextDevicePathNode (DevicePath)) { > -- > 2.18.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel