[parted-devel] [PATCH 1/2] libparted: gpt: compare first and last usable LBAs
Davidlohr Bueso
dave at gnu.org
Fri Sep 7 17:55:45 UTC 2012
When verifying GPT header integrity, make sure that
first usable LBA is smaller than last usable LBA.
---
libparted/labels/gpt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6032e3f..6dfaf3e 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -650,6 +650,11 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
return 0;
PedSector first_usable = PED_LE64_TO_CPU (gpt->FirstUsableLBA);
+ PedSector last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
+
+ if (last_usable < first_usable)
+ return 0;
+
if (first_usable < 3)
return 0;
--
1.7.9.5
More information about the parted-devel
mailing list