windows: do not use winsock2 inet_ntop()
/inet_pton()
#16577
Closed
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.
Disable these winsock2 functions on Windows to use the curl wrappers
and preserve
WSAGetLastError()
akaSOCKERRNO
error codes.curl sources uses
inet_pton()
andinet_ntop()
via its ownCurl_
prefixed wrappers. These wrappers promise to not overwrite
WSAGetLastError()
akaSOCKERRNO
error codes when calling them.But, for Windows builds with these built-in winsock2 functions detected
(meaning all supported Windows versions, except Windows CE),
the wrappers were 1-to-1 mapped to the winsock2 functions, which broke
this promise.
curl/lib/inet_ntop.c
Lines 188 to 190 in b06c12b
curl/lib/inet_pton.c
Lines 66 to 70 in b06c12b
These promises are old (a1d5983) and
may not be valid anymore. In this case, the callers would have to be
updated to use
SOCKERRNO
to retrieve any error, instead of usingerrno
as they do now.https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop
https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_pton