Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using GetAddrInfoExW when impersonation is used #13738

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/asyn-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
10 changes: 10 additions & 0 deletions lib/system_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions lib/system_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading