diff options
| author | andretuta <andreviniciusmerlia@gmail.com> | 2026-11-24 02:42:07 -0300 |
|---|---|---|
| committer | andretuta <andreviniciusmerlia@gmail.com> | 2026-11-24 02:42:07 -0300 |
| commit | d7cdfcf25500503fbd694fb6eb949b694ae71bdf (patch) | |
| tree | b373008d61f4d167d4f30bccd6ad803aa6b6aa14 /runtime/shims/registry.cpp | |
| parent | 7f7a5968563718098c3c592193ecb8da14e7d49a (diff) | |
ws2_offline: per-socket extension pointers, refuse name-service lookups, close connect-by-name and octal bypasses, cover wsock32
Review fixes for #357:
- ConnectEx / WSASendMsg wrappers ask the host for the pointer of the socket they run on, instead of one
process-wide pointer that the last WSAIoctl on any provider overwrote.
- WSALookupServiceBeginA/W fail with WSASERVICE_NOT_FOUND.
- WSAConnectByNameA/W hand the host the literal 127.0.0.1 for "localhost", so the hosts file is never read.
- A dotted octet with a leading zero (0127.0.0.1) is refused: Windows reads it as octal.
- wsock32.dll maps bind/connect/sendto/gethostby*/WSAAsyncGetHostBy* (names and ordinals) to the same wrappers and
stays host-owned in owns_dll, like ws2_32.dll.
- docs/runtime_imports.md no longer says a --run can open real sockets; it names the dnsapi.dll gap.
Tested: ws2_offline_test built with clang 23 (msys2 clang64) on Windows: 52 checks, 0 failures. MSVC build not
available locally; CI covers it. tests/test_docs_*.py, test_text_write_line_endings.py, test_runtime_paths.py pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/registry.cpp')
| -rw-r--r-- | runtime/shims/registry.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/shims/registry.cpp b/runtime/shims/registry.cpp index 1abd5afdc..f041df89f 100644 --- a/runtime/shims/registry.cpp +++ b/runtime/shims/registry.cpp | |||
| @@ -494,7 +494,8 @@ void* find(const std::string& dll_lower, const std::string& name) { | |||
| 494 | 494 | ||
| 495 | bool owns_dll(const std::string& dll_lower) { | 495 | bool owns_dll(const std::string& dll_lower) { |
| 496 | static const char* const host[] = {"kernel32.dll", "kernelbase.dll", "msvcrt.dll", "ucrtbase.dll", "ucrtbased.dll", | 496 | static const char* const host[] = {"kernel32.dll", "kernelbase.dll", "msvcrt.dll", "ucrtbase.dll", "ucrtbased.dll", |
| 497 | "vulkan-1.dll", "ntdll.dll", "user32.dll", "ws2_32.dll"}; | 497 | "vulkan-1.dll", "ntdll.dll", "user32.dll", "ws2_32.dll", |
| 498 | "wsock32.dll"}; | ||
| 498 | if (starts_with(dll_lower, "api-ms-") || starts_with(dll_lower, "ext-ms-")) return false; | 499 | if (starts_with(dll_lower, "api-ms-") || starts_with(dll_lower, "ext-ms-")) return false; |
| 499 | for (const char* h : host) | 500 | for (const char* h : host) |
| 500 | if (dll_lower == h) return false; | 501 | if (dll_lower == h) return false; |