[PATCH] gpt: fix a bug in the new PE-array CRC checks on big-endian systems

Jim Meyering meyering at redhat.com
Tue Nov 10 14:20:08 UTC 2009


* libparted/labels/gpt.c (check_PE_array_CRC, gpt_read): Always
convert the PartitionEntryArrayCRC32 to CPU endianness before
comparing with a just-computed CRC.
---
 libparted/labels/gpt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 8b77c51..5037d9b 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -642,7 +642,7 @@ check_PE_array_CRC (PedDisk const *disk,
     return 1;

   uint32_t ptes_crc = efi_crc32 (ptes, ptes_bytes);
-  *valid = (ptes_crc == gpt->PartitionEntryArrayCRC32);
+  *valid = (ptes_crc == PED_LE32_TO_CPU (gpt->PartitionEntryArrayCRC32));
   free (ptes);
   return 0;
 }
@@ -1032,7 +1032,7 @@ gpt_read (PedDisk *disk)
     goto error_free_gpt;

   uint32_t ptes_crc = efi_crc32 (ptes, ptes_bytes);
-  if (ptes_crc != gpt->PartitionEntryArrayCRC32)
+  if (ptes_crc != PED_LE32_TO_CPU (gpt->PartitionEntryArrayCRC32))
     {
       ped_exception_throw
         (PED_EXCEPTION_ERROR,
--
1.6.5.2.351.g0943



More information about the parted-devel mailing list