parted/0021-gpt-require-first_usable_LBA-last_usable_LBA.patch
Brian C. Lane 0b7af917e2 - Rebase on new upstream master commit cc382c3
- Drop patches incorporated into upstream
- Still adds the various DASD patches
2014-04-08 11:46:37 -07:00

32 lines
1003 B
Diff

From 46d9108009ccb9ac567cc285a15efb05864932d5 Mon Sep 17 00:00:00 2001
From: Davidlohr Bueso <dave@gnu.org>
Date: Tue, 11 Sep 2012 19:22:32 +0200
Subject: [PATCH 21/89] 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.
---
libparted/labels/gpt.c | 4 ++++
1 file changed, 4 insertions(+)
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)
--
1.8.5.3