summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorJian J Wang <jian.j.wang@intel.com>2019-01-25 22:12:25 +0800
committerJian J Wang <jian.j.wang@intel.com>2019-02-21 20:54:31 +0800
commit2f7a96d6ec13b292d6f31295f3195913921173e1 (patch)
tree1bbc9f4d882d87c545a09506bdde78a6e46a4798 /MdePkg/Library
parentb6f67b4d58b81f12f63f5f8c94cf8af3600297ab (diff)
downloadedk2-2f7a96d6ec13b292d6f31295f3195913921173e1.tar.gz
edk2-2f7a96d6ec13b292d6f31295f3195913921173e1.tar.bz2
edk2-2f7a96d6ec13b292d6f31295f3195913921173e1.zip
MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497 Current implementation of IsDevicePathValid() is not enough for type of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device path. This patch add a simple NULL character check at Length position. Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
index 5d7635fe3e..dd1bddc1c2 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
@@ -95,6 +95,15 @@ IsDevicePathValid (
return FALSE;
}
}
+
+ //
+ // FilePath must be a NULL-terminated string.
+ //
+ if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
+ *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
+ return FALSE;
+ }
}
//