[edk2] [PATCH 5/5] BaseTools/DevicePath: Fix potential null pointer dereference

Hao Wu posted 5 patches 6 years, 11 months ago
[edk2] [PATCH 5/5] BaseTools/DevicePath: Fix potential null pointer dereference
Posted by Hao Wu 6 years, 11 months ago
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 BaseTools/Source/C/DevicePath/DevicePath.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c
index 4f859a0e44..b67ff412eb 100644
--- a/BaseTools/Source/C/DevicePath/DevicePath.c
+++ b/BaseTools/Source/C/DevicePath/DevicePath.c
@@ -183,6 +183,11 @@ int main(int argc, CHAR8 *argv[])
   }
   Ascii2UnicodeString(Str, Str16);
   DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);
+  if (DevicePath == NULL) {
+    fprintf(stderr, "Convert fail, Cannot convert text to a device path");
+    free(Str16);
+    return STATUS_ERROR;
+  }
   while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )
   {
     PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);
-- 
2.12.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel