Fix spurious warnings of problems on MBR disks

This commit is contained in:
Rod Smith
2021-02-01 10:19:50 -05:00
parent 6180deb472
commit f063fe08e4
3 changed files with 21 additions and 6 deletions

7
NEWS
View File

@@ -1,3 +1,10 @@
1.0.7 (?/??/2021):
------------------
- Fixed bug that caused spurious warnings about the partition table
header claiming an invalid size of partition entries when reading
some MBR disks.
1.0.6 (1/13/2021):
------------------

8
gpt.cc
View File

@@ -1042,10 +1042,18 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector
*crcOk = CheckHeaderCRC(&tempHeader);
if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
// Print the below warning only if the CRC is OK -- but correct the
// problem either way. The warning is printed only on a valid CRC
// because otherwise this warning will display inappropriately when
// reading MBR disks. If the CRC is invalid, then a warning about
// that will be shown later, so the user will still know that
// something is wrong.
if (*crcOk) {
cerr << "Warning: Partition table header claims that the size of partition table\n";
cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
cerr << "Adjusting accordingly, but partition table may be garbage.\n";
}
tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
}

View File

@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <string>
#define GPTFDISK_VERSION "1.0.6"
#define GPTFDISK_VERSION "1.0.6.1"
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64