From a9681c0c2af5db968defa1b4e87b4c4cc2c29ca4 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 10 Nov 2020 17:30:49 +0000 Subject: [PATCH] [core] fix a possible crash in DeletePartition() with a blank disk * For blank disks, GetVdsDiskInterface() may return success with a NULL pAdvancedDisk. * Also silence the annoying "Failed to read label" error on ERROR_UNRECOGNIZED_VOLUME. --- src/drive.c | 7 ++++++- src/rufus.rc | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/drive.c b/src/drive.c index cc966d6b..6b324cd6 100644 --- a/src/drive.c +++ b/src/drive.c @@ -683,6 +683,10 @@ BOOL DeletePartition(DWORD DriveIndex, ULONGLONG PartitionOffset, BOOL bSilent) if (!GetVdsDiskInterface(DriveIndex, &IID_IVdsAdvancedDisk, (void**)&pAdvancedDisk, bSilent)) return FALSE; + if (pAdvancedDisk == NULL) { + suprintf("No partition to delete on disk"); + return TRUE; + } // Query the partition data, so we can get the start offset, which we need for deletion hr = IVdsAdvancedDisk_QueryPartitions(pAdvancedDisk, &prop_array, &prop_array_size); @@ -1222,7 +1226,8 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label) *label = (char*)GetExtFsLabel(DriveIndex, 0); if (*label == NULL) { SetLastError(error); - duprintf("Failed to read label: %s", WindowsErrorString()); + if (error != ERROR_UNRECOGNIZED_VOLUME) + duprintf("Failed to read label: %s", WindowsErrorString()); *label = STR_NO_LABEL; } } diff --git a/src/rufus.rc b/src/rufus.rc index a2c2f3b1..147bd154 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.13.1721" +CAPTION "Rufus 3.13.1722" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,13,1721,0 - PRODUCTVERSION 3,13,1721,0 + FILEVERSION 3,13,1722,0 + PRODUCTVERSION 3,13,1722,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.13.1721" + VALUE "FileVersion", "3.13.1722" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.13.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.13.1721" + VALUE "ProductVersion", "3.13.1722" END END BLOCK "VarFileInfo"