[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 233/411: strerror: Revert to local codepage for Windows error st
From: |
gnunet |
Subject: |
[gnurl] 233/411: strerror: Revert to local codepage for Windows error string |
Date: |
Wed, 13 Jan 2021 01:20:48 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit a32687798122fd9d4263caaf3ea844462bd69f50
Author: Jay Satiro <raysatiro@yahoo.com>
AuthorDate: Tue Oct 13 03:22:55 2020 -0400
strerror: Revert to local codepage for Windows error string
- Change get_winapi_error() to return the error string in the local
codepage instead of UTF-8 encoding.
Two weeks ago bed5f84 fixed get_winapi_error() to work on xbox, but it
also changed the error string's encoding from local codepage to UTF-8.
We return the local codepage version of the error string because if it
is output to the user's terminal it will likely be with functions which
expect the local codepage (eg fprintf, failf, infof).
This is essentially a partial revert of bed5f84. The support for xbox
remains but the error string is reverted back to local codepage.
Ref: https://github.com/curl/curl/pull/6005
Reviewed-by: Marcel Raad
Closes #6065
---
lib/strerror.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/lib/strerror.c b/lib/strerror.c
index 0a3b73844..b5808df2d 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -44,7 +44,6 @@
#endif
#include "strerror.h"
-#include "curl_multibyte.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -656,26 +655,26 @@ static const char *
get_winapi_error(int err, char *buf, size_t buflen)
{
char *p;
+ wchar_t wbuf[256];
if(!buflen)
return NULL;
*buf = '\0';
-
- {
- TCHAR wbuf[256];
- wbuf[0] = L'\0';
-
- if(FormatMessage((FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
- LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(TCHAR), NULL)) {
- char *msg = curlx_convert_tchar_to_UTF8(wbuf);
- if(msg) {
- strncpy(buf, msg, buflen - 1);
- buf[buflen-1] = '\0';
- curlx_unicodefree(msg);
- }
- }
+ *wbuf = L'\0';
+
+ /* We return the local codepage version of the error string because if it is
+ output to the user's terminal it will likely be with functions which
+ expect the local codepage (eg fprintf, failf, infof).
+ FormatMessageW -> wcstombs is used for Windows CE compatibility. */
+ if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
+ LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
+ size_t written = wcstombs(buf, wbuf, buflen - 1);
+ if(written != (size_t)-1)
+ buf[written] = '\0';
+ else
+ *buf = '\0';
}
/* Truncate multiple lines */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 153/411: github: remove the duplicate "Security vulnerability" entry, (continued)
- [gnurl] 153/411: github: remove the duplicate "Security vulnerability" entry, gnunet, 2021/01/12
- [gnurl] 158/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 183/411: Curl_send: return error when pre_receive_plain can't malloc, gnunet, 2021/01/12
- [gnurl] 162/411: docs/TheArtOfHttpScripting: convert to markdown, gnunet, 2021/01/12
- [gnurl] 149/411: multi: reuse WinSock events variable in Curl_multi_wait, gnunet, 2021/01/12
- [gnurl] 148/411: TODO: dynamically decide to use socketpair, gnunet, 2021/01/12
- [gnurl] 139/411: tool_writeout: add new writeout variable, %{num_headers}, gnunet, 2021/01/12
- [gnurl] 182/411: ftp: separate FTPS from FTP over "HTTPS proxy", gnunet, 2021/01/12
- [gnurl] 197/411: configure: use "no" instead of "disabled" for the end summary, gnunet, 2021/01/12
- [gnurl] 232/411: CI/tests: use verification curl for test reporting APIs, gnunet, 2021/01/12
- [gnurl] 233/411: strerror: Revert to local codepage for Windows error string,
gnunet <=
- [gnurl] 226/411: mbedtls: add missing header when defining MBEDTLS_DEBUG, gnunet, 2021/01/12
- [gnurl] 159/411: CHECKSRC: document two missing warnings, gnunet, 2021/01/12
- [gnurl] 133/411: curl: make file2memory use dynbuf, gnunet, 2021/01/12
- [gnurl] 154/411: man pages: switch to https://example.com URLs, gnunet, 2021/01/12
- [gnurl] 259/411: packages/OS400: make the source code-style compliant, gnunet, 2021/01/12
- [gnurl] 241/411: src/tool_filetime: disable -Wformat on mingw for this file, gnunet, 2021/01/12
- [gnurl] 132/411: curl: make file2string use dynbuf, gnunet, 2021/01/12
- [gnurl] 180/411: pingpong: use a dynbuf for the *_pp_sendf() function, gnunet, 2021/01/12
- [gnurl] 143/411: test3015: verify stdout "as text", gnunet, 2021/01/12
- [gnurl] 150/411: multi: align WinSock mask variables in Curl_multi_wait, gnunet, 2021/01/12