]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
MdeModulePkg/UdfDxe: Add more check when getting PD from LongAd
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / UdfDxe / FileSystemOperations.c
index f1205bbb8eed2b890367beabbe563ece04a71292..cabb599695aaa684476263e108d2a2315e83ab48 100644 (file)
@@ -242,11 +242,16 @@ GetPdFromLongAd (
     //\r
     // NOTE: Only one Type 1 (Physical) Partition is supported. It has been\r
     // checked already in Partition driver for existence of a single Type 1\r
-    // Partition map, so we don't have to double check here.\r
+    // Partition map. Hence, the 'PartitionReferenceNumber' field (the index\r
+    // used to access Partition Maps data within the Logical Volume Descriptor)\r
+    // in the Long Allocation Descriptor should be 0 to indicate there is only\r
+    // one partition.\r
     //\r
-    // Partition reference number can also be retrieved from\r
-    // LongAd->ExtentLocation.PartitionReferenceNumber, however the spec says\r
-    // it may be 0, so let's not rely on it.\r
+    if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) {\r
+      return NULL;\r
+    }\r
+    //\r
+    // Since only one partition, get the first one directly.\r
     //\r
     PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]);\r
     break;\r