strerr: correct the strerror_s() return code condition#20955
Closed
strerr: correct the strerror_s() return code condition#20955
Conversation
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 1eca08a Pointed out by Codex Security
There was a problem hiding this comment.
Pull request overview
Fixes Windows error-string formatting in curlx_strerror() by correcting the strerror_s() return-code check so that the Winsock/WinAPI fallback path is only used when strerror_s() fails or yields "Unknown error".
Changes:
- Correct the
strerror_s()success/failure condition in the Windows branch ofcurlx_strerror(). - Prevent valid CRT errno messages from being overwritten by the fallback logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
vszakats
approved these changes
Mar 17, 2026
Member
|
I did test this locally because I'm prone to get such conditions Here are the difference before and after (with WINE): |
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Mar 17, 2026
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Mar 18, 2026
and a fix for Windows error message texts: curl/curl@e894699 curl/curl#20955
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 1eca08a
Pointed out by Codex Security