From: Hao Wu Date: Wed, 3 Jan 2018 11:31:37 +0000 (+0800) Subject: BaseTools/DevicePath: Fix potential null pointer dereference X-Git-Tag: edk2-stable201903~2618 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=e73fbac5d7f7c4ecb803991839c054a682f991d4 BaseTools/DevicePath: Fix potential null pointer dereference Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Yonghong Zhu Reviewed-by: Liming Gao --- diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c index 9185b89e35..956bbffb5f 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);