diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2021-09-16 23:47:08 -0400 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2021-09-17 03:44:54 -0400 |
commit | b0eda8dc6eb7be3d3e0762be5fb2a60989c2f77b (patch) | |
tree | 6bca73b524e71e29816f3f1c8a1d27de3ec6a767 /lib/strerror.c | |
parent | 4a4617756acd49abcee478e8d40f2061aa5413e7 (diff) | |
download | curl-b0eda8dc6eb7be3d3e0762be5fb2a60989c2f77b.tar.gz |
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 to 2f0bb86 which 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: https://github.com/curl/curl/commit/2f0bb86
Closes https://github.com/curl/curl/pull/7735
Diffstat (limited to 'lib/strerror.c')
-rw-r--r-- | lib/strerror.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/strerror.c b/lib/strerror.c index 431ff1c2f..8a2719765 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -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); |