From 07cf042ececdcdc2b731c7a2040a48f21dde85b6 Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Sat, 9 Nov 2019 18:07:59 -0500 Subject: strerror: Fix an error looking up some Windows error strings - Use FORMAT_MESSAGE_IGNORE_INSERTS to ignore format specifiers in Windows error strings. Since we are not in control of the error code we don't know what information may be needed by the error string's format specifiers. Prior to this change Windows API error strings which contain specifiers (think specifiers like similar to printf specifiers) would not be shown. The FormatMessage Windows API call which turns a Windows error code into a string could fail and set error ERROR_INVALID_PARAMETER if that error string contained a format specifier. FormatMessage expects a va_list for the specifiers, unless inserts are ignored in which case no substitution is attempted. Ref: https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353 --- tests/server/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/server/util.c b/tests/server/util.c index cc53d3bf4..263f0cece 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -150,7 +150,8 @@ void win32_perror(const char *msg) char buf[512]; DWORD err = SOCKERRNO; - if(!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, LANG_NEUTRAL, buf, sizeof(buf), NULL)) msnprintf(buf, sizeof(buf), "Unknown error %lu (%#lx)", err, err); if(msg) -- cgit v1.2.3