From 98725a0d5f49ad36be1ddf89bd362fbaf2f025f4 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 8 Sep 2023 16:57:39 +0100 Subject: [PATCH] [misc] fix improper processing of net related errors * With thanks to @Wack0 * Also silence a Coverity warning --- src/rufus.rc | 10 +++++----- src/stdio.c | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/rufus.rc b/src/rufus.rc index 133e3e0f..693165dd 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.3.2080" +CAPTION "Rufus 4.3.2081" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,3,2080,0 - PRODUCTVERSION 4,3,2080,0 + FILEVERSION 4,3,2081,0 + PRODUCTVERSION 4,3,2081,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.3.2080" + VALUE "FileVersion", "4.3.2081" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.3.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.3.2080" + VALUE "ProductVersion", "4.3.2081" END END BLOCK "VarFileInfo" diff --git a/src/stdio.c b/src/stdio.c index fe80dc0f..95ba5634 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -233,8 +234,11 @@ const char *WindowsErrorString(void) error_code = GetLastError(); // Check for specific facility error codes switch (HRESULT_FACILITY(error_code)) { - case FACILITY_HTTP: - hModule = GetModuleHandleA("wininet.dll"); + case FACILITY_NULL: + // Special case for internet related errors, that don't actually have a facility + // set but still require a hModule into wininet to display the messages. + if ((error_code >= INTERNET_ERROR_BASE) && (error_code <= INTERNET_ERROR_LAST)) + hModule = GetModuleHandleA("wininet.dll"); break; case FACILITY_ITF: hModule = GetModuleHandleA("vdsutil.dll"); @@ -248,6 +252,7 @@ const char *WindowsErrorString(void) static_sprintf(err_string, "[0x%08lX] ", error_code); presize = (DWORD)strlen(err_string); + // coverity[var_deref_model] size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | ((hModule != NULL) ? FORMAT_MESSAGE_FROM_HMODULE : 0), hModule, HRESULT_CODE(error_code), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),