Blame SOURCES/gdisk-CVE-2020-0256.patch

9e4196
From e44306f00bd12f4dca2db20eaba103ff2f260d87 Mon Sep 17 00:00:00 2001
9e4196
From: Rod Smith <rodsmith@rodsbooks.com>
9e4196
Date: Mon, 14 Sep 2020 10:08:18 -0400
9e4196
Subject: [PATCH 1/2] Fix segfault on some weird data structures
9e4196
9e4196
---
9e4196
 gpt.cc | 13 ++++++++++++-
9e4196
 1 file changed, 12 insertions(+), 1 deletion(-)
9e4196
9e4196
diff --git a/gpt.cc b/gpt.cc
9e4196
index 03a2156..d0242d3 100644
9e4196
--- a/gpt.cc
9e4196
+++ b/gpt.cc
9e4196
@@ -983,6 +983,14 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector
9e4196
    } // if
9e4196
    *crcOk = CheckHeaderCRC(&tempHeader);
9e4196
 
9e4196
+   if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
9e4196
+       cerr << "Warning: Partition table header claims that the size of partition table\n";
9e4196
+       cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
9e4196
+       cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
9e4196
+       cerr << "Adjusting accordingly, but partition table may be garbage.\n";
9e4196
+       tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
9e4196
+   }
9e4196
+
9e4196
    if (allOK && (numParts != tempHeader.numParts) && *crcOk) {
9e4196
       allOK = SetGPTSize(tempHeader.numParts, 0);
9e4196
    }
9e4196
@@ -1000,7 +1008,10 @@ int GPTData::LoadPartitionTable(const struct GPTHeader & header, DiskIO & disk,
9e4196
    uint32_t sizeOfParts, newCRC;
9e4196
    int retval;
9e4196
 
9e4196
-   if (disk.OpenForRead()) {
9e4196
+   if (header.sizeOfPartitionEntries != sizeof(GPTPart)) {
9e4196
+      cerr << "Error! GPT header contains invalid partition entry size!\n";
9e4196
+      retval = 0;
9e4196
+   } else if (disk.OpenForRead()) {
9e4196
       if (sector == 0) {
9e4196
          retval = disk.Seek(header.partitionEntriesLBA);
9e4196
       } else {
9e4196
-- 
9e4196
2.35.1
9e4196