[misc] fix division by zero if the sector size is misreported

* It looks like some disks may report a sector size of zero
* Hopefully, this will address #352 (but some report about the
  detected sector size from people observing the crash would be nice)
This commit is contained in:
Pete Batard 2014-08-03 19:34:01 +01:00
parent 270ad743ab
commit 60c66ef813
3 changed files with 14 additions and 7 deletions

View file

@ -431,6 +431,8 @@ static BOOL FormatFAT32(DWORD DriveIndex)
}
memcpy(&dgDrive, &xdgDrive->Geometry, sizeof(dgDrive));
}
if (dgDrive.BytesPerSector < 512)
dgDrive.BytesPerSector = 512;
if (IS_ERROR(FormatStatus)) goto out;
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive,
sizeof(piDrive), &cbRet, NULL)) {