]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/DevicePath: Fix potential null pointer dereference
authorHao Wu <hao.a.wu@intel.com>
Wed, 3 Jan 2018 11:31:37 +0000 (19:31 +0800)
committerHao Wu <hao.a.wu@intel.com>
Mon, 15 Jan 2018 02:42:17 +0000 (10:42 +0800)
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/DevicePath/DevicePath.c

index 9185b89e35e21e62b9360f0636da1330aa757053..956bbffb5f245de17957a437493e000881678b2d 100644 (file)
@@ -183,6 +183,11 @@ int main(int argc, CHAR8 *argv[])
   }\r
   Ascii2UnicodeString(Str, Str16);\r
   DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);\r
+  if (DevicePath == NULL) {\r
+    fprintf(stderr, "Convert fail, Cannot convert text to a device path");\r
+    free(Str16);\r
+    return STATUS_ERROR;\r
+  }\r
   while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )\r
   {\r
     PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);\r