Skip to content

curlx/strerr: use strerror_s() on Windows - #19646

Closed
vszakats wants to merge 2 commits into
curl:masterfrom
vszakats:wstrerr
Closed

curlx/strerr: use strerror_s() on Windows#19646
vszakats wants to merge 2 commits into
curl:masterfrom
vszakats:wstrerr

Conversation

@vszakats

@vszakats vszakats commented Nov 22, 2025

Copy link
Copy Markdown
Member

To replace deprecated, unsafe sys_nerr, sys_errlist global
variables with the function suggested by the CRT warning silenced via
_CRT_SECURE_NO_WARNINGS:

lib/curlx/strerr.c(291): warning C4996: '__sys_nerr': This function or variable may be unsafe. Consider using strerror instead.
lib/curlx/strerr.c(292): warning C4996: '__sys_errlist': This function or variable may be unsafe. Consider using strerror instead.

(where strerror in turn suggests strerror_s...)

Upside: returns an error and has a Unicode variant. Downaside: happy
to return success when passing unrecognized error codes. Work it around
by looking for the string "Unknown error" returned in such cases and
falling back to other methods to retrieve a description.

Refs:
https://learn.microsoft.com/cpp/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr
https://learn.microsoft.com/cpp/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s


https://github.com/curl/curl/pull/19646/files?w=1

@vszakats vszakats added the Windows Windows-specific label Nov 22, 2025
@vszakats
vszakats marked this pull request as draft November 22, 2025 01:38
@testclutch

This comment was marked as off-topic.

@vszakats
vszakats marked this pull request as ready for review November 22, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

2 participants