curl/lib/system_win32.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.7 KiB
C
Raw Normal View History

#ifndef HEADER_CURL_SYSTEM_WIN32_H
#define HEADER_CURL_SYSTEM_WIN32_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
2020-11-04 21:02:01 +08:00
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "curl_setup.h"
asyn-thread: stop using GetAddrInfoExW on Windows - For the threaded resolver backend on Windows, revert back to exclusively use the threaded resolver with libcurl-owned threading instead of GetAddrInfoExW with Windows-owned threading. Winsock (the Windows sockets library) has a bug where it does not wait for all of the name resolver threads it is managing to terminate before returning from WSACleanup. The threads continue to run and may cause a crash. This commit is effectively a revert of several commits that encompass all GetAddrInfoExW code in libcurl. A manual review of merge conflicts was used to resolve minor changes that had modified the code for aesthetic or build reasons in other commits. Prior to this change if libcurl was built with the threaded resolver backend for Windows, and Windows 8 or later was the operating system at runtime, and the caller was not impersonating another user, then libcurl would use GetAddrInfoExW to handle asynchronous name lookups. GetAddrInfoExW support was added in a6bbc87f, which preceded 8.6.0, and prior to that the threaded resolver backend used libcurl-owned threading exclusively on Windows. Reported-by: Ionuț-Francisc Oancea Reported-by: Razvan Pricope Ref: https://developercommunity.visualstudio.com/t/ASAN:-heap-use-after-free-in-NdrFullPoin/10654169 Fixes https://github.com/curl/curl/issues/13509#issuecomment-2225338110 Closes https://github.com/curl/curl/pull/14794 --- Revert "asyn-thread: avoid using GetAddrInfoExW with impersonation" This reverts commit 0caadc1f24d20514eed2bf6e5ef0adc140f122c3. Conflicts: lib/system_win32.c -- Revert "asyn-thread: fix curl_global_cleanup crash in Windows" This reverts commit 428579f5d136fd473e97fe089c42ffee55b72a8f. -- Revert "system_win32: fix a function pointer assignment warning" This reverts commit 26f002e02ef1142a432c8dc087bd27de71ce38bf. -- Revert "asyn-thread: use GetAddrInfoExW on >= Windows 8" This reverts commit a6bbc87f9e9ffb46a1801dfb983e7534825ed56b. Conflicts: lib/asyn-thread.c lib/system_win32.c --
2024-09-05 14:18:25 +08:00
#if defined(_WIN32)
#include <curl/curl.h>
extern LARGE_INTEGER Curl_freq;
extern bool Curl_isVistaOrGreater;
CURLcode Curl_win32_init(long flags);
void Curl_win32_cleanup(long init_flags);
/* We use our own typedef here since some headers might lack this */
typedef unsigned int(WINAPI *IF_NAMETOINDEX_FN)(const char *);
2019-06-20 15:39:10 +08:00
/* This is used instead of if_nametoindex if available on Windows */
extern IF_NAMETOINDEX_FN Curl_if_nametoindex;
/* This is used to dynamically load DLLs */
HMODULE Curl_load_library(LPCTSTR filename);
#else /* _WIN32 */
#define Curl_win32_init(x) CURLE_OK
#endif /* !_WIN32 */
#endif /* HEADER_CURL_SYSTEM_WIN32_H */