gptfdisk/fix-spurious-warnings.patch
Jan Engelhardt 538e7babd2 Accepting request 872678 from home:manfred999:branches:filesystems
- fix regression from version 1.0.6: misleading warning when reading MBR disks,
    upstream commit f063fe08e424c99f133df18bf9dce49c851bcb0a

OBS-URL: https://build.opensuse.org/request/show/872678
OBS-URL: https://build.opensuse.org/package/show/filesystems/gptfdisk?expand=0&rev=18
2021-02-26 18:19:52 +00:00

34 lines
1.7 KiB
Diff

Commit f063fe08e424c99f133df18bf9dce49c851bcb0a:
Fixed bug that caused spurious warnings about the partition table
header claiming an invalid size of partition entries when reading
some MBR disks.
See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981231
--- a/gpt.cc
+++ b/gpt.cc
@@ -1042,11 +1042,19 @@
*crcOk = CheckHeaderCRC(&tempHeader);
if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
- 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);
+ // 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);
}
if (allOK && (numParts != tempHeader.numParts) && *crcOk) {