]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
authorJian J Wang <jian.j.wang@intel.com>
Fri, 25 Jan 2019 14:12:25 +0000 (22:12 +0800)
committerJian J Wang <jian.j.wang@intel.com>
Thu, 21 Feb 2019 12:54:31 +0000 (20:54 +0800)
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>
MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c

index 5d7635fe3eddcb17b0923a97384bffc386387671..dd1bddc1c2eb446c62ba826ff847b708645cc476 100644 (file)
@@ -95,6 +95,15 @@ IsDevicePathValid (
         return FALSE;\r
       }\r
     }\r
         return FALSE;\r
       }\r
     }\r
+\r
+    //\r
+    // FilePath must be a NULL-terminated string.\r
+    //\r
+    if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&\r
+        DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&\r
+        *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {\r
+      return FALSE;\r
+    }\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r