mirror of
https://github.com/curl/curl.git
synced 2025-01-30 14:22:33 +08:00
asyn-thread: avoid using GetAddrInfoExW with impersonation
Multiple reports suggest that GetAddrInfoExW fails when impersonation is used. This PR checks if thread is impersonating and avoids using GetAddrInfoExW api. Reported-by: Keerthi Timmaraju Assisted-by: edmcln on github Fixes #13612 Closes #13738
This commit is contained in:
parent
30de937bda
commit
0caadc1f24
@ -638,7 +638,8 @@ static bool init_resolve_thread(struct Curl_easy *data,
|
||||
|
||||
#ifdef _WIN32
|
||||
if(Curl_isWindows8OrGreater && Curl_FreeAddrInfoExW &&
|
||||
Curl_GetAddrInfoExCancel && Curl_GetAddrInfoExW) {
|
||||
Curl_GetAddrInfoExCancel && Curl_GetAddrInfoExW &&
|
||||
!Curl_win32_impersonating()) {
|
||||
#define MAX_NAME_LEN 256 /* max domain name is 253 chars */
|
||||
#define MAX_PORT_LEN 8
|
||||
WCHAR namebuf[MAX_NAME_LEN];
|
||||
|
@ -267,4 +267,14 @@ HMODULE Curl_load_library(LPCTSTR filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Curl_win32_impersonating(void)
|
||||
{
|
||||
HANDLE token = NULL;
|
||||
if(OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &token)) {
|
||||
CloseHandle(token);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
@ -68,6 +68,8 @@ extern FREEADDRINFOEXW_FN Curl_FreeAddrInfoExW;
|
||||
extern GETADDRINFOEXCANCEL_FN Curl_GetAddrInfoExCancel;
|
||||
extern GETADDRINFOEXW_FN Curl_GetAddrInfoExW;
|
||||
|
||||
bool Curl_win32_impersonating(void);
|
||||
|
||||
/* This is used to dynamically load DLLs */
|
||||
HMODULE Curl_load_library(LPCTSTR filename);
|
||||
#else /* _WIN32 */
|
||||
|
Loading…
Reference in New Issue
Block a user