mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-22 02:45:11 -04:00
[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:
parent
270ad743ab
commit
60c66ef813
3 changed files with 14 additions and 7 deletions
|
@ -602,7 +602,7 @@ int GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSyst
|
||||||
FileSystemName[0] = 0;
|
FileSystemName[0] = 0;
|
||||||
volume_name = GetLogicalName(DriveIndex, TRUE, FALSE);
|
volume_name = GetLogicalName(DriveIndex, TRUE, FALSE);
|
||||||
if ((volume_name == NULL) || (!GetVolumeInformationA(volume_name, NULL, 0, NULL, NULL, NULL, FileSystemName, FileSystemNameSize))) {
|
if ((volume_name == NULL) || (!GetVolumeInformationA(volume_name, NULL, 0, NULL, NULL, NULL, FileSystemName, FileSystemNameSize))) {
|
||||||
uprintf("No volume information for disk 0x%02x\n", DriveIndex);
|
uprintf("No volume information for drive 0x%02x\n", DriveIndex);
|
||||||
}
|
}
|
||||||
safe_free(volume_name);
|
safe_free(volume_name);
|
||||||
|
|
||||||
|
@ -617,6 +617,11 @@ int GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSyst
|
||||||
safe_closehandle(hPhysical);
|
safe_closehandle(hPhysical);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (DiskGeometry->Geometry.BytesPerSector < 512) {
|
||||||
|
uprintf("WARNING: Drive 0x%02x reports a sector size of %d - Correcting to 512 bytes.\n",
|
||||||
|
DriveIndex, DiskGeometry->Geometry.BytesPerSector);
|
||||||
|
DiskGeometry->Geometry.BytesPerSector = 512;
|
||||||
|
}
|
||||||
SelectedDrive.DiskSize = DiskGeometry->DiskSize.QuadPart;
|
SelectedDrive.DiskSize = DiskGeometry->DiskSize.QuadPart;
|
||||||
memcpy(&SelectedDrive.Geometry, &DiskGeometry->Geometry, sizeof(DISK_GEOMETRY));
|
memcpy(&SelectedDrive.Geometry, &DiskGeometry->Geometry, sizeof(DISK_GEOMETRY));
|
||||||
uprintf("Disk type: %s, Sector Size: %d bytes\n", (DiskGeometry->Geometry.MediaType == FixedMedia)?"Fixed":"Removable",
|
uprintf("Disk type: %s, Sector Size: %d bytes\n", (DiskGeometry->Geometry.MediaType == FixedMedia)?"Fixed":"Removable",
|
||||||
|
|
|
@ -431,6 +431,8 @@ static BOOL FormatFAT32(DWORD DriveIndex)
|
||||||
}
|
}
|
||||||
memcpy(&dgDrive, &xdgDrive->Geometry, sizeof(dgDrive));
|
memcpy(&dgDrive, &xdgDrive->Geometry, sizeof(dgDrive));
|
||||||
}
|
}
|
||||||
|
if (dgDrive.BytesPerSector < 512)
|
||||||
|
dgDrive.BytesPerSector = 512;
|
||||||
if (IS_ERROR(FormatStatus)) goto out;
|
if (IS_ERROR(FormatStatus)) goto out;
|
||||||
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive,
|
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive,
|
||||||
sizeof(piDrive), &cbRet, NULL)) {
|
sizeof(piDrive), &cbRet, NULL)) {
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
|
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Rufus 1.4.10.507"
|
CAPTION "Rufus 1.4.10.508"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||||
|
@ -165,7 +165,7 @@ END
|
||||||
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||||
CAPTION "Rufus 1.4.10.507"
|
CAPTION "Rufus 1.4.10.508"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||||
|
@ -428,8 +428,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,4,10,507
|
FILEVERSION 1,4,10,508
|
||||||
PRODUCTVERSION 1,4,10,507
|
PRODUCTVERSION 1,4,10,508
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -446,13 +446,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.4.10.507"
|
VALUE "FileVersion", "1.4.10.508"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "1.4.10.507"
|
VALUE "ProductVersion", "1.4.10.508"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue