From e73fbac5d7f7c4ecb803991839c054a682f991d4 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Wed, 3 Jan 2018 19:31:37 +0800 Subject: [PATCH] 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 --- 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 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); -- 2.39.2