Skip to content

Commit

Permalink
[misc] fix improper processing of net related errors
Browse files Browse the repository at this point in the history
* With thanks to @Wack0
* Also silence a Coverity warning
  • Loading branch information
pbatard committed Sep 8, 2023
1 parent 94ecf74 commit 98725a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions src/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wininet.h>
#include <winternl.h>
#include <dbghelp.h>
#include <assert.h>
Expand Down Expand Up @@ -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");
Expand All @@ -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),
Expand Down

0 comments on commit 98725a0

Please sign in to comment.