Abort load of too-small disk image

This commit is contained in:
Rod Smith
2022-04-10 10:25:41 -04:00
parent 4be26d7228
commit 6b7486db99

10
gpt.cc
View File

@@ -886,8 +886,16 @@ int GPTData::LoadPartitions(const string & deviceFilename) {
break;
} // switch
if (allOK)
if (allOK) {
CheckGPTSize();
// Below is unlikely to happen on real disks, but could happen if
// the user is manipulating a truncated image file....
if (diskSize <= GetTableSizeInSectors() * 2 + 3) {
allOK = 0;
cout << "Disk is too small to hold GPT data (" << diskSize
<< " sectors)! Aborting!\n";
}
}
myDisk.Close();
ComputeAlignment();
} else {