mirror of
https://github.com/curl/curl.git
synced 2026-04-15 04:11:41 +03:00
strerror: use sys_errlist instead of strerror on Windows
- Change Curl_strerror to use sys_errlist[errnum] instead of strerror to retrieve the error message on Windows. Windows' strerror writes to a static buffer and is not thread-safe. Follow-up to2f0bb86which removed most instances of strerror in favor of calling Curl_strerror (which calls strerror_r for other platforms). Ref: https://github.com/curl/curl/pull/7685 Ref:2f0bb86Closes https://github.com/curl/curl/pull/7735
This commit is contained in:
parent
4a4617756a
commit
b0eda8dc6e
1 changed files with 2 additions and 2 deletions
|
|
@ -731,12 +731,11 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
|
|||
max = buflen - 1;
|
||||
*buf = '\0';
|
||||
|
||||
/* !checksrc! disable STRERROR 2 */
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#if defined(WIN32)
|
||||
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
|
||||
if(err >= 0 && err < sys_nerr)
|
||||
strncpy(buf, strerror(err), max);
|
||||
strncpy(buf, sys_errlist[err], max);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -787,6 +786,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
|
|||
}
|
||||
#else
|
||||
{
|
||||
/* !checksrc! disable STRERROR 1 */
|
||||
const char *msg = strerror(err);
|
||||
if(msg)
|
||||
strncpy(buf, msg, max);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue