Commit 23d85e6e authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

dnsapi: Return a double-null-terminated string from DnsQueryConfig(DnsConfigSearchList).

DNS_TEXT_DATA contains pointers and is thus not WoW64 compatible. Since the API is internal to Wine, use a simpler format instead of fixing our WoW64 translation. The problem was found by Brendan Shanks; this solution was suggested by Hans Leidekker.
parent 91083d45
......@@ -128,7 +128,7 @@ extern const char *debugstr_type( unsigned short ) DECLSPEC_HIDDEN;
struct get_searchlist_params
{
DNS_TXT_DATAW *list;
WCHAR *list;
DWORD *len;
};
......
......@@ -125,16 +125,15 @@ static DNS_STATUS map_h_errno( int error )
static NTSTATUS resolv_get_searchlist( void *args )
{
const struct get_searchlist_params *params = args;
DNS_TXT_DATAW *list = params->list;
DWORD i, needed, str_needed = 0;
WCHAR *list = params->list;
DWORD i, needed = 0;
WCHAR *ptr, *end;
init_resolver();
for (i = 0; i < MAXDNSRCH + 1 && _res.dnsrch[i]; i++)
str_needed += (strlen(_res.dnsrch[i]) + 1) * sizeof(WCHAR);
needed = FIELD_OFFSET(DNS_TXT_DATAW, pStringArray[i]) + str_needed;
needed += (strlen(_res.dnsrch[i]) + 1) * sizeof(WCHAR);
needed += sizeof(WCHAR); /* null terminator */
if (!list || *params->len < needed)
{
......@@ -143,16 +142,12 @@ static NTSTATUS resolv_get_searchlist( void *args )
}
*params->len = needed;
list->dwStringCount = i;
ptr = (WCHAR *)(list->pStringArray + i);
end = ptr + str_needed / sizeof(WCHAR);
ptr = list;
end = ptr + needed / sizeof(WCHAR);
for (i = 0; i < MAXDNSRCH + 1 && _res.dnsrch[i]; i++)
{
list->pStringArray[i] = ptr;
ptr += ntdll_umbstowcs( _res.dnsrch[i], strlen(_res.dnsrch[i]) + 1,
list->pStringArray[i], end - ptr );
}
ptr += ntdll_umbstowcs( _res.dnsrch[i], strlen(_res.dnsrch[i]) + 1, ptr, end - ptr );
*ptr = 0; /* null terminator */
return ERROR_SUCCESS;
}
......
......@@ -1138,7 +1138,7 @@ static DWORD dns_info_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG family, ULONG flags
DWORD err, i, size, attempt, sockaddr_len;
WCHAR name[MAX_ADAPTER_NAME_LENGTH + 1];
DNS_ADDR_ARRAY *servers;
DNS_TXT_DATAW *search;
WCHAR *search;
while (aa)
{
......@@ -1192,9 +1192,9 @@ static DWORD dns_info_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG family, ULONG flags
(search = heap_alloc( size )))
{
if (!DnsQueryConfig( DnsConfigSearchList, 0, name, NULL, search, &size ) &&
search->dwStringCount && wcslen( search->pStringArray[0] ) < MAX_DNS_SUFFIX_STRING_LENGTH)
search[0] && wcslen( search ) < MAX_DNS_SUFFIX_STRING_LENGTH)
{
wcscpy( aa->DnsSuffix, search->pStringArray[0] );
wcscpy( aa->DnsSuffix, search );
}
heap_free( search );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment