* [PATCH v2 0/2] Add a checking step in MdePkg and Basetools
@ 2018-12-12 3:10 Shenglei Zhang
2018-12-12 3:10 ` [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Shenglei Zhang
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
0 siblings, 2 replies; 6+ messages in thread
From: Shenglei Zhang @ 2018-12-12 3:10 UTC (permalink / raw)
To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu, Michael D Kinney
Add a checking step to verify DevicePath.
https://bugzilla.tianocore.org/show_bug.cgi?id=1372
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Shenglei Zhang (2):
MdePkg/UefiDevicePathLib: Add a checking step
BaseTools/DevicePath: Add a checking step
.../Source/C/DevicePath/DevicePathUtilities.c | 17 ++++++++---------
MdePkg/Include/Library/DevicePathLib.h | 3 ++-
.../UefiDevicePathLib/DevicePathUtilities.c | 17 ++++++++---------
3 files changed, 18 insertions(+), 19 deletions(-)
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step
2018-12-12 3:10 [PATCH v2 0/2] Add a checking step in MdePkg and Basetools Shenglei Zhang
@ 2018-12-12 3:10 ` Shenglei Zhang
2019-01-29 3:08 ` Gao, Liming
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
1 sibling, 1 reply; 6+ messages in thread
From: Shenglei Zhang @ 2018-12-12 3:10 UTC (permalink / raw)
To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu
Add a checking step in DevicePathUtilities.c
to verify DevicePath.
https://bugzilla.tianocore.org/show_bug.cgi?id=1372
v2: Remove ASSERT() and the redundant checking step.
Update related description.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
.../Source/C/DevicePath/DevicePathUtilities.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/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 mUefiDevicePathLibEndDevicePath = {
/**
Determine whether a given device path is valid.
- If DevicePath is NULL, then ASSERT().
@param DevicePath A pointer to a device path data structure.
@param MaxSize The maximum size of the device path data structure.
@retval TRUE DevicePath is valid.
+ @retval FALSE DevicePath is NULL.
+ @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE The length of any node node in the DevicePath is less
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;
- ASSERT (DevicePath != NULL);
+ //
+ // Validate the input whether exists and its size big enough to touch the first node
+ //
+ if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
+ return FALSE;
+ }
if (MaxSize == 0) {
MaxSize = MAX_UINT32;
- }
-
- //
- // Validate the input size big enough to touch the first node.
- //
- if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
- return FALSE;
}
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
--
2.18.0.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step
2018-12-12 3:10 [PATCH v2 0/2] Add a checking step in MdePkg and Basetools Shenglei Zhang
2018-12-12 3:10 ` [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Shenglei Zhang
@ 2018-12-12 3:10 ` Shenglei Zhang
2019-01-29 1:29 ` Gao, Liming
2019-01-29 3:41 ` Ni, Ray
1 sibling, 2 replies; 6+ messages in thread
From: Shenglei Zhang @ 2018-12-12 3:10 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Michael D Kinney
Add a checking step in DevicePathUtilities.c to verify the DevicePath.
https://bugzilla.tianocore.org/show_bug.cgi?id=1372
v2: Remove ASSERT() and the redundant checking step.
Update related description in DevicePathLib.h
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
MdePkg/Include/Library/DevicePathLib.h | 2 +-
.../UefiDevicePathLib/DevicePathUtilities.c | 14 ++++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
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.
/**
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.
@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;
- ASSERT (DevicePath != NULL);
-
- if (MaxSize == 0) {
- MaxSize = 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 the first node
//
- if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
+ if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
return FALSE;
}
+ if (MaxSize == 0) {
+ MaxSize = MAX_UINTN;
+ }
+
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
--
2.18.0.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
@ 2019-01-29 1:29 ` Gao, Liming
2019-01-29 3:41 ` Ni, Ray
1 sibling, 0 replies; 6+ messages in thread
From: Gao, Liming @ 2019-01-29 1:29 UTC (permalink / raw)
To: Zhang, Shenglei, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Gao, Liming
Shenglei:
The patch is good. Reviewed-by: Liming Gao <liming.gao@intel.com>
Besides, this patch is from MS Mu project. Please keep original patch author. You don't need to send this patch again.
Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Shenglei Zhang
> Sent: Wednesday, December 12, 2018 11:10 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step
>
> Add a checking step in DevicePathUtilities.c to verify the DevicePath.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1372
>
> v2: Remove ASSERT() and the redundant checking step.
> Update related description in DevicePathLib.h
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> MdePkg/Include/Library/DevicePathLib.h | 2 +-
> .../UefiDevicePathLib/DevicePathUtilities.c | 14 ++++++--------
> 2 files changed, 7 insertions(+), 9 deletions(-)
>
> 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.
>
> /**
> 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.
>
> @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;
>
> - ASSERT (DevicePath != NULL);
> -
> - if (MaxSize == 0) {
> - MaxSize = 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 the first node
> //
> - if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
> + if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
> return FALSE;
> }
>
> + if (MaxSize == 0) {
> + MaxSize = MAX_UINTN;
> + }
> +
> for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
> NodeLength = DevicePathNodeLength (DevicePath);
> if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
> --
> 2.18.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step
2018-12-12 3:10 ` [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Shenglei Zhang
@ 2019-01-29 3:08 ` Gao, Liming
0 siblings, 0 replies; 6+ messages in thread
From: Gao, Liming @ 2019-01-29 3:08 UTC (permalink / raw)
To: Zhang, Shenglei, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Shenglei Zhang
> Sent: Wednesday, December 12, 2018 11:10 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step
>
> Add a checking step in DevicePathUtilities.c
> to verify DevicePath.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1372
>
> v2: Remove ASSERT() and the redundant checking step.
> Update related description.
>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> .../Source/C/DevicePath/DevicePathUtilities.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/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 mUefiDevicePathLibEndDevicePath = {
>
> /**
> Determine whether a given device path is valid.
> - If DevicePath is NULL, then ASSERT().
>
> @param DevicePath A pointer to a device path data structure.
> @param MaxSize The maximum size of the device path data structure.
>
> @retval TRUE DevicePath is valid.
> + @retval FALSE DevicePath is NULL.
> + @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOCOL).
> @retval FALSE The length of any node node in the DevicePath is less
> 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;
>
> - ASSERT (DevicePath != NULL);
> + //
> + // Validate the input whether exists and its size big enough to touch the first node
> + //
> + if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
> + return FALSE;
> + }
>
> if (MaxSize == 0) {
> MaxSize = MAX_UINT32;
> - }
> -
> - //
> - // Validate the input size big enough to touch the first node.
> - //
> - if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
> - return FALSE;
> }
>
> for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
> --
> 2.18.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking step
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
2019-01-29 1:29 ` Gao, Liming
@ 2019-01-29 3:41 ` Ni, Ray
1 sibling, 0 replies; 6+ messages in thread
From: Ni, Ray @ 2019-01-29 3:41 UTC (permalink / raw)
To: Zhang, Shenglei, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Gao, Liming
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Shenglei
> Zhang
> Sent: Wednesday, December 12, 2018 11:10 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <liming.gao@intel.com>
> Subject: [edk2] [PATCH v2 2/2] MdePkg/UefiDevicePathLib: Add a checking
> step
>
> Add a checking step in DevicePathUtilities.c to verify the DevicePath.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1372
>
> v2: Remove ASSERT() and the redundant checking step.
> Update related description in DevicePathLib.h
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> MdePkg/Include/Library/DevicePathLib.h | 2 +-
> .../UefiDevicePathLib/DevicePathUtilities.c | 14 ++++++--------
> 2 files changed, 7 insertions(+), 9 deletions(-)
>
> 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.
>
> /**
> 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.
>
> @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;
>
> - ASSERT (DevicePath != NULL);
> -
> - if (MaxSize == 0) {
> - MaxSize = 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 the
> first node
> //
> - if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
> + if (DevicePath == NULL || (MaxSize > 0 && MaxSize <
> END_DEVICE_PATH_LENGTH)) {
> return FALSE;
> }
>
> + if (MaxSize == 0) {
> + MaxSize = MAX_UINTN;
> + }
> +
> for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath =
> NextDevicePathNode (DevicePath)) {
> NodeLength = DevicePathNodeLength (DevicePath);
> if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
> --
> 2.18.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-29 3:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12 3:10 [PATCH v2 0/2] Add a checking step in MdePkg and Basetools Shenglei Zhang
2018-12-12 3:10 ` [PATCH v2 2/2] BaseTools/DevicePath: Add a checking step Shenglei Zhang
2019-01-29 3:08 ` Gao, Liming
2018-12-12 3:10 ` [PATCH v2 2/2] MdePkg/UefiDevicePathLib: " Shenglei Zhang
2019-01-29 1:29 ` Gao, Liming
2019-01-29 3:41 ` Ni, Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox