]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
strerr: correct the strerror_s() return code condition
authorDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2026 12:23:30 +0000 (13:23 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2026 13:45:01 +0000 (14:45 +0100)
In curlx_strerror on Windows, the condition checks `!strerror_s(...)`
(true on success) and therefore always evaluates the fallback block.
Even when strerror_s successfully produced a valid errno message.

Follow-up to 1eca08a54177403205014

Pointed out by Codex Security
Closes #20955

lib/curlx/strerr.c

index 91a329e91502c28ae79cb6d0498a0807a22c6505..b53173c57839eb5d0259959701435018ab00817a 100644 (file)
@@ -263,7 +263,7 @@ const char *curlx_strerror(int err, char *buf, size_t buflen)
   *buf = '\0';
 
 #ifdef _WIN32
-  if((!strerror_s(buf, buflen, err) || !strcmp(buf, "Unknown error")) &&
+  if((strerror_s(buf, buflen, err) || !strcmp(buf, "Unknown error")) &&
 #ifdef USE_WINSOCK
      !get_winsock_error(err, buf, buflen) &&
 #endif