]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathUtilities.c
index 5d7635fe3eddcb17b0923a97384bffc386387671..dd1bddc1c2eb446c62ba826ff847b708645cc476 100644 (file)
@@ -95,6 +95,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