[parted-devel] [PATCH] More correct handling of the HeaderSize field in GPT labels
Matthew S. Harris
mharris312 at gmail.com
Sun Jul 8 19:27:07 UTC 2007
I'm trying one more time to try to get my bugfixes into Parted.
Attached is a small patch for making Parted more understanding of GPT
labels generated by ZFS on OpenSolaris. You already have my copyright
assignment form. If there's anything else you need me to do before
you can apply this, please be as explicit as possible, as I am very
unfamiliar with Git.
I have at least one more small patch I'll send after this one is taken care of.
Thanks.
Matthew
-------------- next part --------------
From 7ac2e9fe24fd420f04aa0cc21523dfc55ac707df Mon Sep 17 00:00:00 2001
From: Matthew S. Harris <mharris at coruscant.(none)>
Date: Sun, 8 Jul 2007 12:14:26 -0700
Subject: [PATCH] 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)>
---
libparted/labels/gpt.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
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,
--
1.4.4.2
More information about the parted-devel
mailing list