summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2018-01-03 19:31:37 +0800
committerHao Wu <hao.a.wu@intel.com>2018-01-15 10:42:17 +0800
commite73fbac5d7f7c4ecb803991839c054a682f991d4 (patch)
treeb8cb30244898e3894f704a7f3a8e3753f0395d03
parent66329d53bde5febe55cb1e8d3352ff94d3773277 (diff)
downloadedk2-e73fbac5d7f7c4ecb803991839c054a682f991d4.zip
edk2-e73fbac5d7f7c4ecb803991839c054a682f991d4.tar.gz
edk2-e73fbac5d7f7c4ecb803991839c054a682f991d4.tar.bz2
BaseTools/DevicePath: Fix potential null pointer dereference
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>
-rw-r--r--BaseTools/Source/C/DevicePath/DevicePath.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c
index 9185b89..956bbff 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);