diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:09:51 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:12:50 -0500 |
| commit | be8570ace18d3144d6cbfc2d57c60e736a1c1465 (patch) | |
| tree | 2aa5c100fb9b4ec22b819333194baeea5d3b7906 /runtime/shims/winhttp_offline.cpp | |
| parent | f99ff6cbdd23a2417af5494497f2f23da67c144a (diff) | |
| parent | d0835dd9f9ec0a88faee510126436f2427854c2e (diff) | |
Merge remote-tracking branch 'origin/main' into triage-r43
# Conflicts:
# docs/runtime_imports.md
# runtime/CMakeLists.txt
# runtime/shims/xgameruntime.cpp
# runtime/test/xmem_test.cpp
# tools/rdna2spirv.py
Diffstat (limited to 'runtime/shims/winhttp_offline.cpp')
| -rw-r--r-- | runtime/shims/winhttp_offline.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/runtime/shims/winhttp_offline.cpp b/runtime/shims/winhttp_offline.cpp index 05cd0de9b..10854d5f2 100644 --- a/runtime/shims/winhttp_offline.cpp +++ b/runtime/shims/winhttp_offline.cpp | |||
| @@ -256,19 +256,37 @@ BOOL WINAPI query_headers(HINTERNET request, DWORD, LPCWSTR, LPVOID, LPDWORD, LP | |||
| 256 | return receive_response(request, nullptr); | 256 | return receive_response(request, nullptr); |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | BOOL WINAPI add_request_headers(HINTERNET request, LPCWSTR, DWORD, DWORD) { | 259 | // Headers WinHTTP would reject. Measured against the host's winhttp.dll (Windows 11 26300): a null or empty block, and |
| 260 | // a block with no ':' in it (which includes one cut short by an explicit length), fail with ERROR_INVALID_PARAMETER; | ||
| 261 | // a length of (DWORD)-1 means the text is NUL-terminated. Nothing is stored: no request is ever sent. | ||
| 262 | bool header_block_valid(LPCWSTR headers, DWORD length) { | ||
| 263 | if (!headers) return false; | ||
| 264 | const size_t count = length == static_cast<DWORD>(-1) ? wcslen(headers) : static_cast<size_t>(length); | ||
| 265 | if (count == 0) return false; | ||
| 266 | for (size_t i = 0; i < count; ++i) { | ||
| 267 | if (headers[i] == L'\0') return false; | ||
| 268 | if (headers[i] == L':') return true; | ||
| 269 | } | ||
| 270 | return false; | ||
| 271 | } | ||
| 272 | |||
| 273 | BOOL WINAPI add_request_headers(HINTERNET request, LPCWSTR headers, DWORD length, DWORD) { | ||
| 260 | DWORD error = 0; | 274 | DWORD error = 0; |
| 261 | Handle* r = acquire(request, false, false, true, error); | 275 | Handle* r = acquire(request, false, false, true, error); |
| 262 | if (!r) return fail(error); | 276 | if (!r) return fail(error); |
| 263 | release(r); | 277 | release(r); |
| 278 | if (!header_block_valid(headers, length)) return fail(ERROR_INVALID_PARAMETER); | ||
| 264 | return TRUE; | 279 | return TRUE; |
| 265 | } | 280 | } |
| 266 | 281 | ||
| 267 | BOOL WINAPI set_timeouts(HINTERNET handle, int, int, int, int) { | 282 | // Measured the same way: 0 and -1 (infinite) are accepted; any other negative value, in any of the four, fails with |
| 283 | // ERROR_INVALID_PARAMETER. | ||
| 284 | BOOL WINAPI set_timeouts(HINTERNET handle, int resolve, int connect, int send, int receive) { | ||
| 268 | DWORD error = 0; | 285 | DWORD error = 0; |
| 269 | Handle* h = acquire(handle, true, true, true, error); | 286 | Handle* h = acquire(handle, true, true, true, error); |
| 270 | if (!h) return fail(error); | 287 | if (!h) return fail(error); |
| 271 | release(h); | 288 | release(h); |
| 289 | if (resolve < -1 || connect < -1 || send < -1 || receive < -1) return fail(ERROR_INVALID_PARAMETER); | ||
| 272 | return TRUE; | 290 | return TRUE; |
| 273 | } | 291 | } |
| 274 | 292 | ||