[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Wed Sep 12 09:05:59 UTC 2012


 libparted/labels/gpt.c |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 46d9108009ccb9ac567cc285a15efb05864932d5
Author: Davidlohr Bueso <dave at gnu.org>
Date:   Tue Sep 11 19:22:32 2012 +0200

    gpt: require first_usable_LBA <= last_usable_LBA
    
    When verifying GPT header integrity, ensure that the
    first usable LBA is no larger than the last usable LBA.
    * libparted/labels/gpt.c (_header_is_valid): Reject a header
    with last_usable < first_usable.

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6032e3f..83e518f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -653,6 +653,10 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
   if (first_usable < 3)
     return 0;
 
+  PedSector last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
+  if (last_usable < first_usable)
+    return 0;
+
   origcrc = gpt->HeaderCRC32;
   gpt->HeaderCRC32 = 0;
   if (pth_crc32 (dev, gpt, &crc) != 0)



More information about the Parted-commits mailing list