-- v2: ntdll: Add some documentation for ntdll_umbstowcs() and ntdll_wcstoumbs(). dnsapi: Return a double-null-terminated string from DnsQueryConfig(DnsConfigSearchList). dnsapi: ntdll_umbstowcs() deals in characters, not bytes. dnsapi: Clarify that Windows does not implement DnsQueryConfig(DnsConfigSearchList).
From: Zebediah Figura zfigura@codeweavers.com
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/dnsapi/libresolv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/dnsapi/libresolv.c b/dlls/dnsapi/libresolv.c index e19e867c76c..51a44f88aa5 100644 --- a/dlls/dnsapi/libresolv.c +++ b/dlls/dnsapi/libresolv.c @@ -127,7 +127,7 @@ 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; - char *ptr, *end; + WCHAR *ptr, *end;
init_resolver();
@@ -145,11 +145,11 @@ static NTSTATUS resolv_get_searchlist( void *args ) *params->len = needed; list->dwStringCount = i;
- ptr = (char *)(list->pStringArray + i); - end = ptr + str_needed; + ptr = (WCHAR *)(list->pStringArray + i); + end = ptr + str_needed / sizeof(WCHAR); for (i = 0; i < MAXDNSRCH + 1 && _res.dnsrch[i]; i++) { - list->pStringArray[i] = (WCHAR *)ptr; + list->pStringArray[i] = ptr; ptr += ntdll_umbstowcs( _res.dnsrch[i], strlen(_res.dnsrch[i]) + 1, list->pStringArray[i], end - ptr ); }
From: Zebediah Figura zfigura@codeweavers.com
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. --- dlls/dnsapi/dnsapi.h | 2 +- dlls/dnsapi/libresolv.c | 21 ++++++++------------- dlls/iphlpapi/iphlpapi_main.c | 6 +++--- 3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/dlls/dnsapi/dnsapi.h b/dlls/dnsapi/dnsapi.h index f27cce9a99d..a81cb712f3e 100644 --- a/dlls/dnsapi/dnsapi.h +++ b/dlls/dnsapi/dnsapi.h @@ -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; };
diff --git a/dlls/dnsapi/libresolv.c b/dlls/dnsapi/libresolv.c index 51a44f88aa5..fd645d53fd7 100644 --- a/dlls/dnsapi/libresolv.c +++ b/dlls/dnsapi/libresolv.c @@ -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; }
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 65d3793011b..a95a581532f 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -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 ); }
From: Zebediah Figura zfigura@codeweavers.com
These functions do match e.g. mbstowcs() and MultiByteToWideChar(), but that fact is not inherently obvious [and they don't match RtlMultiByteToUnicodeN(), for example.] --- dlls/ntdll/unix/env.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index a71df03966f..f69e4e80f0d 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -364,6 +364,13 @@ static BOOL is_dynamic_env_var( const char *var )
/****************************************************************** * ntdll_umbstowcs (ntdll.so) + * + * Convert a multi-byte string in the Unix code page to UTF-16. Returns the + * number of characters converted, which may be less than the entire source + * string. The destination string must not be NULL. + * + * The size of the output buffer, and the return value, are both given in + * characters, not bytes. */ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) { @@ -381,6 +388,11 @@ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
/****************************************************************** * ntdll_wcstoumbs (ntdll.so) + * + * Convert a UTF-16 string to a multi-byte string in the Unix code page. + * The destination string must not be NULL. + * + * The size of the source string is given in characters, not bytes. */ int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) {
This merge request was approved by Huw Davies.
This merge request was approved by Hans Leidekker.