curl-curl/scripts
Viktor Szakats 51d8213579
core: stop redefining E* macros on Windows, map EACCES, related fixes
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 abf80aae38 #16612
Follow-up to d69425ed7d #16615
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377

Closes #16621
2025-03-13 00:03:25 +01:00
..
cd2cd docs: introduce "curldown" for libcurl man page format 2024-01-23 00:29:02 +01:00
cd2nroff cd2nroff: do not insist on quoted <> within backticks 2025-01-28 17:36:55 +01:00
cdall docs: introduce "curldown" for libcurl man page format 2024-01-23 00:29:02 +01:00
checksrc.pl core: stop redefining E* macros on Windows, map EACCES, related fixes 2025-03-13 00:03:25 +01:00
ciconfig.pl tidy-up: use /usr/bin/env perl shebang 2024-06-26 23:58:10 +02:00
cijobs.pl GHA: tidy up apt commands 2025-01-30 02:36:43 +01:00
cmakelint.sh cmake: add integration tests, run them in CI 2025-02-07 00:15:48 +01:00
completion.pl completion.pl: add completion for paths after @ for fish 2025-01-10 08:37:55 +01:00
contributors.sh contributors.sh: lowercase 'github' for consistency 2025-02-24 08:05:06 +01:00
contrithanks.sh delta: get contributors without changing THANKS 2025-02-24 13:26:48 +01:00
coverage.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
delta delta: get contributors without changing THANKS 2025-02-24 13:26:48 +01:00
dmaketgz dmaketgz: use --no-cache when building docker image 2024-12-05 15:41:53 +01:00
firefox-db2pem.sh firefox-db2pem: mention what "certutil" the script uses 2024-09-06 08:57:34 +02:00
installcheck.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
Makefile.am scripts/mdlinkcheck: markdown link checker 2024-12-14 14:22:30 +01:00
maketgz Makefile.dist: delete 2025-01-27 20:59:47 +01:00
managen managen: accept more markdown-quote-markers 2025-03-12 14:36:11 +01:00
mdlinkcheck scripts/mdlinkcheck: fix the ../ handling in file links 2024-12-21 13:57:38 +01:00
mk-ca-bundle.pl mk-ca-bundle: remove CKA_NSS_SERVER_DISTRUST_AFTER conditions 2024-11-12 08:33:57 +01:00
mk-unity.pl autotools: add support for 'unity' builds, enable in CI 2024-09-20 23:53:33 +02:00
nroff2cd tidy-up: one comment and EOF newlines 2024-03-12 15:38:44 +00:00
release-notes.pl release-notes.pl: manage more "closes" typos 2025-02-08 10:51:27 +01:00
release-tools.sh maketgz: fix RELEASE-TOOLS.md for daily tarballs 2024-09-07 09:33:09 -07:00
schemetable.c WebSockets: make support official (non-experimental) 2024-09-27 13:20:25 +02:00
singleuse.pl https-rr: implementation improvements 2025-02-18 16:12:26 +01:00
verify-release configure: fail if PSL is not disabled but not found 2024-08-05 08:33:58 +02:00