[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 16/151: strerror: Fix an error looking up some Windows error str
From: |
gnunet |
Subject: |
[gnurl] 16/151: strerror: Fix an error looking up some Windows error strings |
Date: |
Fri, 20 Dec 2019 14:25:25 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 07cf042ececdcdc2b731c7a2040a48f21dde85b6
Author: Jay Satiro <address@hidden>
AuthorDate: Sat Nov 9 18:07:59 2019 -0500
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
---
lib/strerror.c | 6 ++++--
tests/server/util.c | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/strerror.c b/lib/strerror.c
index d0650d80c..7aaa9f4a7 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -670,7 +670,8 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
wchar_t wbuf[256];
wbuf[0] = L'\0';
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
+ FormatMessage((FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL);
wcstombs(buf, wbuf, max);
}
@@ -680,7 +681,8 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
strncpy(buf, strerror(err), max);
else {
if(!get_winsock_error(err, buf, max) &&
- !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
+ !FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
LANG_NEUTRAL, buf, (DWORD)max, NULL))
msnprintf(buf, max, "Unknown error %d (%#x)", err, err);
}
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)
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 06/151: mailmap: fixup Massimiliano Fantuzzi, (continued)
- [gnurl] 06/151: mailmap: fixup Massimiliano Fantuzzi, gnunet, 2019/12/20
- [gnurl] 05/151: scripts/contributors: make committers get included too, gnunet, 2019/12/20
- [gnurl] 04/151: configure: fix typo in help text, gnunet, 2019/12/20
- [gnurl] 10/151: checksrc: repair the copyrightyear check, gnunet, 2019/12/20
- [gnurl] 11/151: test1560: require IPv6 for IPv6 aware URL parsing, gnunet, 2019/12/20
- [gnurl] 03/151: ntlm: USE_WIN32_CRYPTO check removed to get USE_NTLM2SESSION set, gnunet, 2019/12/20
- [gnurl] 07/151: curlver: bump to 7.67.1, gnunet, 2019/12/20
- [gnurl] 01/151: configure: avoid unportable `==' test(1) operator, gnunet, 2019/12/20
- [gnurl] 22/151: quiche: reject headers in the wrong order, gnunet, 2019/12/20
- [gnurl] 13/151: TODO: Run web-platform-tests url tests, gnunet, 2019/12/20
- [gnurl] 16/151: strerror: Fix an error looking up some Windows error strings,
gnunet <=
- [gnurl] 21/151: openssl: prevent recursive function calls from ctx callbacks, gnunet, 2019/12/20
- [gnurl] 18/151: test1558: use double slash after file:, gnunet, 2019/12/20
- [gnurl] 12/151: TODO: 1.4 alt-svc sharing, gnunet, 2019/12/20
- [gnurl] 19/151: remove_handle: clear expire timers after multi_done(), gnunet, 2019/12/20
- [gnurl] 15/151: system.h: fix for MCST lcc compiler, gnunet, 2019/12/20
- [gnurl] 08/151: RELEASE-NOTES: synced, gnunet, 2019/12/20
- [gnurl] 24/151: curl: fix -T globbing, gnunet, 2019/12/20
- [gnurl] 20/151: CURL-DISABLE: initial docs for the CURL_DISABLE_* defines, gnunet, 2019/12/20
- [gnurl] 23/151: HISTORY: added cmake, HTTP/3 and parallel downloads with curl, gnunet, 2019/12/20
- [gnurl] 09/151: copyrights: fix copyright year range, gnunet, 2019/12/20