tool_doswin: fix to use curl socket functions

Replace `WSASocketW()` with `CURL_SOCKET()`. Also replace a call
to `socketclose()` with `sclose()`. According to a comment,
`socketclose()` was chosen to silence test 1498 (and 2300) reporting
`MEMORY FAILURE`. These reports were accurate, and were caused by
calling `WSASocketW()` instead of `socket()` (now `CURL_SOCKET()`).

This also fixes the curl `sclose()` call on an error branch, which is
now correctly paired with a curl socket open. The mismatched open/close
calls caused an issue in TrackMemory-enabled (aka `CURLDEBUG`) builds.

Docs confirm that `socket()` is defaulting to overlapped I/O, matching
the replaced `WSASocketW()` call:
https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-socket#remarks

Also:
- checksrc: ban `WSASocket*()` functions.
- report `SOCKERRNO` instead of `GetLastError()` for socket calls,
  to match the rest of the codebase.

Follow-up to 9a2663322c #17572

Closes #18633
This commit is contained in:
Viktor Szakats 2025-09-20 13:34:08 +02:00
parent 1f0f0bdb19
commit c9eff26c17
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 14 additions and 13 deletions

View file

@ -74,6 +74,9 @@ my %banfunc = (
"LoadLibraryEx" => 1,
"LoadLibraryExA" => 1,
"LoadLibraryExW" => 1,
"WSASocket" => 1,
"WSASocketA" => 1,
"WSASocketW" => 1,
"_waccess" => 1,
"_access" => 1,
"access" => 1,