[parted-devel] [PATCH 2/2] libparted: gpt: verify header is outside usable area

Davidlohr Bueso dave at gnu.org
Fri Sep 7 17:55:54 UTC 2012


The first usable logical block can be used by a GUID partition
entry, and therefore cannot be used by the header.
---
 libparted/labels/gpt.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6dfaf3e..42e702d 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -652,6 +652,9 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
   PedSector first_usable = PED_LE64_TO_CPU (gpt->FirstUsableLBA);
   PedSector last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
 
+  if (first_usable < my_lba && last_usable > my_lba)
+    return 0;
+
   if (last_usable < first_usable)
     return 0;
 
-- 
1.7.9.5







More information about the parted-devel mailing list