[edk2] [PATCH 1/2] BaseTools/DevicePath: Add a checking step

Shenglei Zhang shenglei.zhang at intel.com
Mon Dec 10 22:30:40 PST 2018


Add a checking step in DevicePathUtilities.c to verify DevicePath.

Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <liming.gao at intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang at intel.com>
---
 BaseTools/Source/C/DevicePath/DevicePathUtilities.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
index f8a41ff97d..e2efaeebf0 100644
--- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
+++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
@@ -59,6 +59,18 @@ IsDevicePathValid (
   UINTN Size;
   UINTN NodeLength;
 
+/**
+  NULL device path is also invalid path.
+  
+  IsDevicePathValid() should return FALSE or TRUE, and not ASSERT().
+
+  This change needs to update IsDevicePathValid() API definition and implementation both.
+
+**/
+  if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {
+	return FALSE;
+  }
+
   ASSERT (DevicePath != NULL);
 
   if (MaxSize == 0) {
-- 
2.18.0.windows.1



More information about the edk2-devel mailing list