From 4d6c8b72d8df026254c8dae3560e5807153a54eb Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 19 Sep 2022 10:37:23 +0200 Subject: [PATCH] [loc] improve fatal error handling on application launch * Remove last ditch effort on systems that are clearly broken for localization and always report an explicit error to the user. * Also update GitHub Actions actions/checkout (Closes #2036). --- .github/workflows/coverity.yml | 2 +- .github/workflows/mingw.yml | 2 +- .github/workflows/vs2022.yml | 2 +- src/rufus.c | 11 ++++++++--- src/rufus.rc | 10 +++++----- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 043e9caa..fff94a13 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 submodules: recursive diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 17bc1f61..ed189fd2 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -53,7 +53,7 @@ jobs: upx - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 submodules: recursive diff --git a/.github/workflows/vs2022.yml b/.github/workflows/vs2022.yml index 73b0061b..4187f8be 100644 --- a/.github/workflows/vs2022.yml +++ b/.github/workflows/vs2022.yml @@ -39,7 +39,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 submodules: recursive diff --git a/src/rufus.c b/src/rufus.c index d95fc9f9..f1ed421e 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -3581,15 +3581,20 @@ skip_args_processing: loc_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_LC_RUFUS_LOC), _RT_RCDATA, "embedded.loc", &loc_size, FALSE); if ( (GetTempFileNameU(temp_dir, APPLICATION_NAME, 0, loc_file) == 0) || (loc_file[0] == 0) ) { - // Last ditch effort to get a loc file - just extract it to the current directory - static_strcpy(loc_file, rufus_loc); + // If we don't have a working temp API, forget it + uprintf("FATAL: Unable to create temp loc file: %s", WindowsErrorString()); + MessageBoxA(NULL, "Unable to create temporary localization file. This application will now exit.", + "Fatal error", MB_ICONSTOP | MB_SYSTEMMODAL); + goto out; } hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if ((hFile == INVALID_HANDLE_VALUE) || (!WriteFileWithRetry(hFile, loc_data, loc_size, &size, WRITE_RETRIES))) { - uprintf("localization: unable to extract '%s': %s", loc_file, WindowsErrorString()); + uprintf("FATAL: Unable to extract loc file '%s': %s", loc_file, WindowsErrorString()); safe_closehandle(hFile); + MessageBoxA(NULL, "Unable to extract localization file. This application will now exit.", + "Fatal error", MB_ICONSTOP | MB_SYSTEMMODAL); goto out; } uprintf("localization: extracted data to '%s'", loc_file); diff --git a/src/rufus.rc b/src/rufus.rc index 08dd85b9..2be9e53d 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.21.1935" +CAPTION "Rufus 3.21.1936" 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,21,1935,0 - PRODUCTVERSION 3,21,1935,0 + FILEVERSION 3,21,1936,0 + PRODUCTVERSION 3,21,1936,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.21.1935" + VALUE "FileVersion", "3.21.1936" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.21.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.21.1935" + VALUE "ProductVersion", "3.21.1936" END END BLOCK "VarFileInfo"