Repository navigation
Conversation
9a77d5b to
8c0709a
Compare
|
Alternate suggestions for the prefix? I'm proposing |
Windows's winsock2 returns socket errors via `WSAGetLastError()` and not via `errno` like most systems out there. This was covered by switching to the `SOCKERRNO` curl macro earlier. But, on Windows the returned socket error codes have different values than the standard POSIX errno values. Existing code was using the POSIX values for all these checks. Meaning they never actually matched on Windows. This patch defines a set of `SOCKERRNO` constants that map to the correct socket error values for Windows and other platforms. The same issue exists in core curl code, which redefines the POSIX errno values to winsock2 ones, breaking non-socket uses on Windows. Cherry-picked from curl#15000 Follow-up to adcfd4f curl#16553 Bug: curl#16553 (comment)
Drop the mapping and check for EAGAIN as-is. This will always fail on Windows. These checks should always also check for the alternate error that's also supported on Windows: SOCKEWOULDBLOCK. All existing checks do that. (They are in sws.c)
3b3d45e to
e84d7ae
Compare
|
One more surprise: edit: It's consistently setting edit2: The Assuming error handling is critical at all here. If it worked for such a long time, maybe it isn't. https://en.wikipedia.org/wiki/Errno.h |
This comment was marked as outdated.
This comment was marked as outdated.
These were not used in curl sources at all. Except `EDQUOT` which was used after `mkdir()` in `src/tool_dirhie.c` for error display. It should not be redefined to a winsock2 error. This makes the "exceeded your quota" error correctly appear on Windows, if detected, after operations that create directories. After this patch there remain 14 `E*` macro redefines on Windows, down from 40 before this patch. Bug: #16553 (comment) Ref: #16612 Ref: #16605 Closes #16615
…ixes
Before this patch, standard `E*` errno codes were redefined on Windows,
onto matching winsock2 `WSA*` error codes, which have different values.
This broke uses where using the `E*` value in non-socket context, or
other places expecting a POSIX `errno`, e.g. file I/O, threads, IDN or
interfacing with dependencies.
Fix it by introducing a curl-specific `SOCKE*` set of macros that map to
`WSA*` on Windows and standard POSIX codes on other platforms. Then
verify and update the code to use `SOCKE*` or `E*` macro depending on
context.
- Add `SOCKE*` macros that map to either winsock2 or POSIX error codes.
And use them with `SOCKERRNO` or in contexts requiring
platform-dependent socket error codes.
This fixes `E*` uses which were supposed be POSIX values, not `WSA*`
socket errors, on Windows:
- lib/curl_multibyte.c
- lib/curl_threads.c
- lib/idn.c
- lib/vtls/gtls.c
- lib/vtls/rustls.c
- src/tool_cb_wrt.c
- src/tool_dirhie.c
- Ban `E*` codes having a `SOCKE*` mapping, via checksrc.
Authored-by: Daniel Stenberg
- Add exceptions for `E*` codes used in file I/O, or other contexts
requiring POSIX error codes.
Also:
- ftp: fix missing `SOCKEACCES` mapping for Windows.
- add `SOCKENOMEM` for `Curl_getaddrinfo()` via `asyn-thread.c`.
- tests/server/sockfilt: fix to set `SOCKERRNO` in local `select()`
override on Windows.
- lib/inet_ntop: fix to return `WSAEINVAL` on Windows, where `ENOSPC` is
used on other platforms. To simulate Windows' built-in `inet_ntop()`,
as tested on a Win10 machine.
Note:
- WINE returns `STATUS_INVALID_PARAMETER` = `0xC000000D`.
- Microsoft documentation says it returns `WSA_INVALID_PARAMETER`
(= `ERROR_INVALID_PARAMETER`) 87:
https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#return-value
- lib/inet_ntop: drop redundant `CURL_SETERRNO(ENOSPC)`.
`inet_ntop4()` already sets it before returning `NULL`.
- replace stray `WSAEWOULDBLOCK` with `USE_WINSOCK` macro to detect
winsock2.
- move existing `SOCKE*` mappings from `tests/server` to
`curl_setup_once.h`.
- add missing `EINTR`, `EINVAL` constants for WinCE.
Follow-up to abf80aa #16612
Follow-up to d69425e #16615
Bug: #16553 (comment)
Closes #16621
Windows's winsock2 returns socket errors via `WSAGetLastError()` and not via `errno` like most systems out there. This was covered by switching to the `SOCKERRNO` curl macro earlier. But, on Windows the returned socket error codes have different values than the standard POSIX errno values. Existing code was using the POSIX values for all these checks. Meaning they never actually matched on Windows. This patch defines a set of `SOCKERRNO` constants that map to the correct socket error values for Windows and other platforms. The reverse issue exists in core curl code, which redefines POSIX errno values to winsock2 ones, breaking non-socket uses on Windows. Cherry-picked from curl#15000 Follow-up to adcfd4f curl#16553 Bug: curl#16553 (comment) Closes curl#16612
These were not used in curl sources at all. Except `EDQUOT` which was used after `mkdir()` in `src/tool_dirhie.c` for error display. It should not be redefined to a winsock2 error. This makes the "exceeded your quota" error correctly appear on Windows, if detected, after operations that create directories. After this patch there remain 14 `E*` macro redefines on Windows, down from 40 before this patch. Bug: curl#16553 (comment) Ref: curl#16612 Ref: curl#16605 Closes curl#16615
…ixes
Before this patch, standard `E*` errno codes were redefined on Windows,
onto matching winsock2 `WSA*` error codes, which have different values.
This broke uses where using the `E*` value in non-socket context, or
other places expecting a POSIX `errno`, e.g. file I/O, threads, IDN or
interfacing with dependencies.
Fix it by introducing a curl-specific `SOCKE*` set of macros that map to
`WSA*` on Windows and standard POSIX codes on other platforms. Then
verify and update the code to use `SOCKE*` or `E*` macro depending on
context.
- Add `SOCKE*` macros that map to either winsock2 or POSIX error codes.
And use them with `SOCKERRNO` or in contexts requiring
platform-dependent socket error codes.
This fixes `E*` uses which were supposed be POSIX values, not `WSA*`
socket errors, on Windows:
- lib/curl_multibyte.c
- lib/curl_threads.c
- lib/idn.c
- lib/vtls/gtls.c
- lib/vtls/rustls.c
- src/tool_cb_wrt.c
- src/tool_dirhie.c
- Ban `E*` codes having a `SOCKE*` mapping, via checksrc.
Authored-by: Daniel Stenberg
- Add exceptions for `E*` codes used in file I/O, or other contexts
requiring POSIX error codes.
Also:
- ftp: fix missing `SOCKEACCES` mapping for Windows.
- add `SOCKENOMEM` for `Curl_getaddrinfo()` via `asyn-thread.c`.
- tests/server/sockfilt: fix to set `SOCKERRNO` in local `select()`
override on Windows.
- lib/inet_ntop: fix to return `WSAEINVAL` on Windows, where `ENOSPC` is
used on other platforms. To simulate Windows' built-in `inet_ntop()`,
as tested on a Win10 machine.
Note:
- WINE returns `STATUS_INVALID_PARAMETER` = `0xC000000D`.
- Microsoft documentation says it returns `WSA_INVALID_PARAMETER`
(= `ERROR_INVALID_PARAMETER`) 87:
https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#return-value
- lib/inet_ntop: drop redundant `CURL_SETERRNO(ENOSPC)`.
`inet_ntop4()` already sets it before returning `NULL`.
- replace stray `WSAEWOULDBLOCK` with `USE_WINSOCK` macro to detect
winsock2.
- move existing `SOCKE*` mappings from `tests/server` to
`curl_setup_once.h`.
- add missing `EINTR`, `EINVAL` constants for WinCE.
Follow-up to abf80aa curl#16612
Follow-up to d69425e curl#16615
Bug: curl#16553 (comment)
Closes curl#16621
Windows's winsock2 returns socket errors via
WSAGetLastError()andnot via
errnolike most systems out there. This was covered byswitching to the
SOCKERRNOcurl macro earlier. But, on Windows thereturned socket error codes have different values than the standard
POSIX errno values. Existing code was using the POSIX values for all
these checks. Meaning they never actually matched on Windows.
This patch defines a set of
SOCKERRNOconstants that map to thecorrect socket error values for Windows and other platforms.
The reverse issue exists in core curl code, which redefines POSIX errno
values to winsock2 ones, breaking non-socket uses on Windows.
Cherry-picked from #15000
Follow-up to adcfd4f #16553
Bug: #16553 (comment)
As for the naming: This uses
SOCKprefix which seemed like the bestquick idea. The cleanest would be a
CURL_SOCKprefix, thenCURL_S,or we may just use
S, likeSEINTR.