]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for FilePath device...
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLibDevicePathProtocol / UefiDevicePathLib.c
index 9a0ee42fd16adcc188235cd7c9766b9f662b3068..c8e78d23737619a7eae8c9b9ffdf2c0789e91cac 100644 (file)
@@ -138,6 +138,15 @@ IsDevicePathValid (
         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