diff --git a/src/rufus.c b/src/rufus.c index e3f38c8b..042f3e9e 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -1605,18 +1605,6 @@ static DWORD WINAPI BootCheckThread(LPVOID param) } } - if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE * MB) && HAS_REGULAR_EFI(img_report) && - (partition_type == PARTITION_STYLE_GPT) && IS_FAT(fs_type) && !esp_already_asked) { - // The ISO is small enough to be written as an ESP and we are using GPT - // so ask the users if they want to write it as an ESP. - char* iso_image = lmprintf(MSG_036); - char* choices[2] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, "ISO → ESP") }; - i = SelectionDialog(lmprintf(MSG_274, "ESP"), lmprintf(MSG_310), choices, 2); - if (i < 0) // Cancel - goto out; - write_as_esp = (i & 2); - } - // Check UEFI bootloaders for revocation if (IS_EFI_BOOTABLE(img_report)) { // coverity[swapped_arguments] @@ -1642,6 +1630,18 @@ static DWORD WINAPI BootCheckThread(LPVOID param) } } + if ((img_report.projected_size < MAX_ISO_TO_ESP_SIZE * MB) && HAS_REGULAR_EFI(img_report) && + (partition_type == PARTITION_STYLE_GPT) && IS_FAT(fs_type) && !esp_already_asked) { + // The ISO is small enough to be written as an ESP and we are using GPT + // so ask the users if they want to write it as an ESP. + char* iso_image = lmprintf(MSG_036); + char* choices[2] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, "ISO → ESP") }; + i = SelectionDialog(lmprintf(MSG_274, "ESP"), lmprintf(MSG_310), choices, 2); + if (i < 0) // Cancel + goto out; + write_as_esp = (i & 2); + } + // If the selected target doesn't include BIOS, skip file downloads for GRUB/Syslinux if (target_type != TT_BIOS) goto uefi_target; @@ -3823,7 +3823,7 @@ extern int TestHashes(void); if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'D')) { static_sprintf(tmp_path, "%s\\%s", app_data_dir, FILES_DIR); PrintStatusDebug(STATUS_MSG_TIMEOUT, MSG_264, tmp_path); - SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION); + SHDeleteDirectoryExU(NULL, tmp_path, FOF_NO_UI); user_deleted_rufus_dir = TRUE; continue; } diff --git a/src/rufus.h b/src/rufus.h index 811ae3a0..c644dda5 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -147,27 +147,29 @@ #define ComboBox_GetCurItemData(hCtrl) ComboBox_GetItemData(hCtrl, ComboBox_GetCurSel(hCtrl)) -#define safe_free(p) do {free((void*)p); p = NULL;} while(0) -#define safe_mm_free(p) do {_mm_free((void*)p); p = NULL;} while(0) -#define safe_min(a, b) min((size_t)(a), (size_t)(b)) -#define safe_strcp(dst, dst_max, src, count) do { size_t _count = (count); memmove(dst, src, safe_min(_count, dst_max)); \ - ((char*)(dst))[safe_min(_count, dst_max)-1] = 0; } while(0) -#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1) +#define safe_free(p) do { free((void*)p); p = NULL; } while(0) +#define safe_mm_free(p) do { _mm_free((void*)p); p = NULL; } while(0) +static __inline void safe_strcp(char* dst, const size_t dst_max, const char* src, const size_t count) { + memmove(dst, src, min(count, dst_max)); + dst[min(count, dst_max) - 1] = 0; +} +#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src) + 1) #define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src) #define safe_strcat(dst, dst_max, src) strncat_s(dst, dst_max, src, _TRUNCATE) #define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src) -#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"":str1), ((str2==NULL)?"":str2)) -#define safe_strstr(str1, str2) strstr(((str1==NULL)?"":str1), ((str2==NULL)?"":str2)) -#define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"":str1), ((str2==NULL)?"":str2)) -#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"":str1), ((str2==NULL)?"":str2), count) -#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"":str1), ((str2==NULL)?"":str2), count) -#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0) -#define safe_release_dc(hDlg, hDC) do {if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) {ReleaseDC(hDlg, hDC); hDC = NULL;}} while(0) -#define safe_sprintf(dst, count, ...) do { size_t _count = (count); _snprintf_s(dst, _count, _TRUNCATE, __VA_ARGS__); (dst)[(_count)-1] = 0; } while(0) +#define safe_strcmp(str1, str2) strcmp(((str1 == NULL) ? "" : str1), ((str2 == NULL) ? "" : str2)) +#define safe_strstr(str1, str2) strstr(((str1 == NULL) ? "" : str1), ((str2 == NULL) ? "" : str2)) +#define safe_stricmp(str1, str2) _stricmp(((str1 == NULL) ? "" : str1), ((str2 == NULL) ? "" : str2)) +#define safe_strncmp(str1, str2, count) strncmp(((str1 == NULL) ? "" : str1), ((str2 == NULL) ? "" : str2), count) +#define safe_strnicmp(str1, str2, count) _strnicmp(((str1 == NULL) ? "" : str1), ((str2 == NULL) ? "" : str2), count) +#define safe_closehandle(h) do { if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) { CloseHandle(h); h = INVALID_HANDLE_VALUE; } } while(0) +#define safe_release_dc(hDlg, hDC) do { if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) { ReleaseDC(hDlg, hDC); hDC = NULL; } } while(0) +#define safe_sprintf(dst, count, ...) do { size_t _count = count; char* _dst = dst; _snprintf_s(_dst, _count, _TRUNCATE, __VA_ARGS__); \ + _dst[(_count) - 1] = 0; } while(0) #define static_sprintf(dst, ...) safe_sprintf(dst, sizeof(dst), __VA_ARGS__) -#define safe_atoi(str) ((((char*)(str))==NULL)?0:atoi(str)) -#define safe_strlen(str) ((((char*)(str))==NULL)?0:strlen(str)) -#define safe_strdup(str) ((((char*)(str))==NULL)?NULL:_strdup(str)) +#define safe_atoi(str) ((((char*)(str))==NULL) ? 0 : atoi(str)) +#define safe_strlen(str) ((((char*)(str))==NULL) ? 0 : strlen(str)) +#define safe_strdup(str) ((((char*)(str))==NULL) ? NULL : _strdup(str)) #if defined(_MSC_VER) #define safe_vsnprintf(buf, size, format, arg) _vsnprintf_s(buf, size, _TRUNCATE, format, arg) #else diff --git a/src/rufus.rc b/src/rufus.rc index 395c840e..2e47aa0a 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 4.5.2157" +CAPTION "Rufus 4.5.2158" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -397,8 +397,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,5,2157,0 - PRODUCTVERSION 4,5,2157,0 + FILEVERSION 4,5,2158,0 + PRODUCTVERSION 4,5,2158,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -416,13 +416,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.5.2157" + VALUE "FileVersion", "4.5.2158" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.5.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.5.2157" + VALUE "ProductVersion", "4.5.2158" END END BLOCK "VarFileInfo"