[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Tue Jul 10 07:02:04 UTC 2007
libparted/labels/gpt.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
New commits:
commit 6be273f13b07f1e6b16922fc1555c12be1427cc0
Author: Matthew S. Harris <mharris312 at gmail.com>
Date: Sun Jul 8 12:27:07 2007 -0700
More correct handling of the HeaderSize field in GPT labels
- Use the HeaderSize field value when determining how many bytes to
compute the CRC over.
- Don't abort if the HeaderSize field value is bigger than our struct,
since more fields may be defined in the future.
Signed-off-by: Matthew S. Harris <mharris at coruscant.(none)>
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 86c31c7..5b3721c 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -390,7 +390,7 @@ pth_crc32(const PedDevice* dev, const GuidPartitionTableHeader_t* pth)
PED_ASSERT (dev != NULL, return 0);
PED_ASSERT (pth != NULL, return 0);
- crc32 = efi_crc32 (pth_raw, pth_get_size_static (dev));
+ crc32 = efi_crc32 (pth_raw, PED_LE32_TO_CPU (pth->HeaderSize));
ped_free (pth_raw);
@@ -590,8 +590,13 @@ _header_is_valid (const PedDevice* dev, GuidPartitionTableHeader_t* gpt)
if (PED_LE64_TO_CPU (gpt->Signature) != GPT_HEADER_SIGNATURE)
return 0;
- if (PED_LE32_TO_CPU (gpt->HeaderSize)
- > pth_get_size_static (dev))
+ /*
+ * "While the GUID Partition Table Header's size may increase
+ * in the future it cannot span more than one block on the
+ * device." EFI Specification, version 1.10, 11.2.2.1
+ */
+ if (PED_LE32_TO_CPU (gpt->HeaderSize) < pth_get_size_static (dev)
+ || PED_LE32_TO_CPU (gpt->HeaderSize) > dev->sector_size)
return 0;
origcrc = gpt->HeaderCRC32;
@@ -639,9 +644,7 @@ _parse_header (PedDisk* disk, GuidPartitionTableHeader_t* gpt,
PED_ASSERT (_header_is_valid (disk->dev, gpt), return 0);
#ifndef DISCOVER_ONLY
- if (PED_LE32_TO_CPU (gpt->Revision) > GPT_HEADER_REVISION_V1_02
- || PED_LE32_TO_CPU (gpt->HeaderSize) != pth_get_size_static (
- disk->dev)) {
+ if (PED_LE32_TO_CPU (gpt->Revision) > GPT_HEADER_REVISION_V1_02) {
if (ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_IGNORE_CANCEL,
More information about the Parted-commits
mailing list