summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2018-10-16 12:16:02 +0800
committerHao Wu <hao.a.wu@intel.com>2018-10-23 14:24:58 +0800
commit85acb5e8ffef026b80241b1657ed4fba26e382b1 (patch)
treeccc0e770198aa4803d14931fa49bd63e9fb0d9b6 /MdeModulePkg/Universal/Disk
parent32698a8f013140b8f77f18a03c64c40ba04c2e18 (diff)
downloadedk2-85acb5e8ffef026b80241b1657ed4fba26e382b1.zip
edk2-85acb5e8ffef026b80241b1657ed4fba26e382b1.tar.gz
edk2-85acb5e8ffef026b80241b1657ed4fba26e382b1.tar.bz2
MdeModulePkg/UdfDxe: Add more check when getting PD from LongAd
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1254 This commit will add an additional check within function GetPdFromLongAd() when getting a Partition Descriptor from given a Long Allocation Descriptor. According to UDF 2.60 Spec, Section 2.2.13: > The partition reference numbers used are determined by the order of the > Partition Maps in the LVD. (Also the picture comes before the above contents) And a more detailed explanation of the partition reference numbers is at https://sites.google.com/site/udfintro/ (seems not a formal documentation though), Section 5.3.6. Based on the above findings, the 'PartitionReferenceNumber' field in a Long Allocation Descriptor is used as an index to access the Partition Maps data within a Logical Volume Descriptor. Hence, the new check focuses on the validity of this 'PartitionReferenceNumber' field in a Long Allocation Descriptor. Since the current implementation of UdfDxe driver supports only one partition on a Logical Volume, so the value of 'PartitionReferenceNumber' should be 0. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/Disk')
-rw-r--r--MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
index f1205bb..cabb599 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
@@ -242,11 +242,16 @@ GetPdFromLongAd (
//
// NOTE: Only one Type 1 (Physical) Partition is supported. It has been
// checked already in Partition driver for existence of a single Type 1
- // Partition map, so we don't have to double check here.
+ // Partition map. Hence, the 'PartitionReferenceNumber' field (the index
+ // used to access Partition Maps data within the Logical Volume Descriptor)
+ // in the Long Allocation Descriptor should be 0 to indicate there is only
+ // one partition.
//
- // Partition reference number can also be retrieved from
- // LongAd->ExtentLocation.PartitionReferenceNumber, however the spec says
- // it may be 0, so let's not rely on it.
+ if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) {
+ return NULL;
+ }
+ //
+ // Since only one partition, get the first one directly.
//
PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]);
break;