Merge branch 'develop' into release/v1.0.0beta

This commit is contained in:
Willem Toorop 2016-03-29 20:40:50 +02:00
commit 64dfed2a07
1 changed files with 24 additions and 9 deletions

View File

@ -845,11 +845,13 @@ upstream_init(getdns_upstream *upstream,
/* /*
Read the Windows search suffix and add to context Read the Windows search suffix and add to context
There may or may not be domains and suffixes so do not error if missing
*/ */
static int get_dns_suffix_windows(getdns_list *suffix) static int get_dns_suffix_windows(getdns_list *suffix, char* domain)
{ {
char *parse, *token, prev_ch; char *parse, *token, prev_ch;
char lszValue[255]; char lszValue[255] = "";
char lszDomain[255] = "";
HKEY hKey; HKEY hKey;
LONG returnStatus; LONG returnStatus;
DWORD dwType=REG_SZ; DWORD dwType=REG_SZ;
@ -871,21 +873,30 @@ static int get_dns_suffix_windows(getdns_list *suffix)
TEXT("SearchList"), 0, &dwType,(LPBYTE)&lszValue, &dwSize); TEXT("SearchList"), 0, &dwType,(LPBYTE)&lszValue, &dwSize);
if (returnStatus == ERROR_SUCCESS) if (returnStatus == ERROR_SUCCESS)
{ {
if ((strlen(lszValue)) > 0) {
parse = lszValue; parse = lszValue;
do { do {
parse += strspn(parse, ","); parse += strspn(parse, ",");
token = parse + strcspn(parse, ","); token = parse + strcspn(parse, ",");
prev_ch = *token; prev_ch = *token;
*token = 0; *token = 0;
_getdns_list_append_string(suffix, parse); _getdns_list_append_string(suffix, parse);
*token = prev_ch; *token = prev_ch;
parse = token; parse = token;
} while (*parse); } while (*parse);
} else {
return 0; /* no DNS suffixes keys */
} }
}
dwSize = 255;
returnStatus = RegQueryValueEx(hKey,
TEXT("Domain"), 0, &dwType,(LPBYTE)&lszDomain, &dwSize);
if (returnStatus == ERROR_SUCCESS)
{
strcpy_s(domain, dwSize, lszDomain);
}
RegCloseKey(hKey); RegCloseKey(hKey);
} else { } else {
return 0; /* no DNS keys or suffixes */ return 0; /* no DNS keys or suffixes */
@ -970,12 +981,16 @@ set_os_defaults_windows(struct getdns_context *context)
suffix = getdns_list_create_with_context(context); suffix = getdns_list_create_with_context(context);
if (get_dns_suffix_windows(suffix)) { if (get_dns_suffix_windows(suffix, domain)) {
(void) getdns_list_get_length(suffix, &length); (void) getdns_list_get_length(suffix, &length);
if (length > 0) if (*domain != 0) {
_getdns_list_append_string(suffix, domain);
}
(void) getdns_list_get_length(suffix, &length);
if (length > 0) {
(void )getdns_context_set_suffix(context, suffix); (void )getdns_context_set_suffix(context, suffix);
} }
}
getdns_list_destroy(suffix); getdns_list_destroy(suffix);
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;