Commit d7430abd authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

secur32: GetComputerObjectName should not set domain part of the name if it is NULL.

LsaQueryInformationPolicy(PolicyDnsDomainInformation) sets both Name and DnsDomainName to NULL when hostname is set to a very long name like "this_is_host.part21.part32.local" and supposedly can't be resolved due to this. Signed-off-by: 's avatarDmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 034e88e0
...@@ -921,7 +921,9 @@ BOOLEAN WINAPI GetComputerObjectNameA( ...@@ -921,7 +921,9 @@ BOOLEAN WINAPI GetComputerObjectNameA(
BOOLEAN rc; BOOLEAN rc;
LPWSTR bufferW = NULL; LPWSTR bufferW = NULL;
ULONG sizeW = *nSize; ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize); TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) { if (lpNameBuffer) {
bufferW = heap_alloc(sizeW * sizeof(WCHAR)); bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) { if (bufferW == NULL) {
...@@ -952,6 +954,7 @@ BOOLEAN WINAPI GetComputerObjectNameW( ...@@ -952,6 +954,7 @@ BOOLEAN WINAPI GetComputerObjectNameW(
PPOLICY_DNS_DOMAIN_INFO domainInfo; PPOLICY_DNS_DOMAIN_INFO domainInfo;
NTSTATUS ntStatus; NTSTATUS ntStatus;
BOOLEAN status; BOOLEAN status;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize); TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (NameFormat == NameUnknown) if (NameFormat == NameUnknown)
...@@ -1000,8 +1003,13 @@ BOOLEAN WINAPI GetComputerObjectNameW( ...@@ -1000,8 +1003,13 @@ BOOLEAN WINAPI GetComputerObjectNameW(
{ {
WCHAR bs[] = { '\\', 0 }; WCHAR bs[] = { '\\', 0 };
WCHAR ds[] = { '$', 0 }; WCHAR ds[] = { '$', 0 };
lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer); if (domainInfo->Name.Buffer)
lstrcatW(lpNameBuffer, bs); {
lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
lstrcatW(lpNameBuffer, bs);
}
else
*lpNameBuffer = 0;
lstrcatW(lpNameBuffer, name); lstrcatW(lpNameBuffer, name);
lstrcatW(lpNameBuffer, ds); lstrcatW(lpNameBuffer, ds);
status = TRUE; status = TRUE;
...@@ -1038,13 +1046,18 @@ BOOLEAN WINAPI GetComputerObjectNameW( ...@@ -1038,13 +1046,18 @@ BOOLEAN WINAPI GetComputerObjectNameW(
} }
len = strlenW(cnW) + size + 1 + strlenW(ComputersW) + 1 + strlenW(dcW); len = strlenW(cnW) + size + 1 + strlenW(ComputersW) + 1 + strlenW(dcW);
suffix = strrchrW(domainInfo->DnsDomainName.Buffer, '.'); if (domainInfo->DnsDomainName.Buffer)
if (suffix)
{ {
*suffix++ = 0; suffix = strrchrW(domainInfo->DnsDomainName.Buffer, '.');
len += 1 + strlenW(dcW) + strlenW(suffix); if (suffix)
{
*suffix++ = 0;
len += 1 + strlenW(dcW) + strlenW(suffix);
}
len += strlenW(domainInfo->DnsDomainName.Buffer);
} }
len += strlenW(domainInfo->DnsDomainName.Buffer); else
suffix = NULL;
if (lpNameBuffer && *nSize > len) if (lpNameBuffer && *nSize > len)
{ {
...@@ -1052,14 +1065,17 @@ BOOLEAN WINAPI GetComputerObjectNameW( ...@@ -1052,14 +1065,17 @@ BOOLEAN WINAPI GetComputerObjectNameW(
lstrcatW(lpNameBuffer, name); lstrcatW(lpNameBuffer, name);
lstrcatW(lpNameBuffer, commaW); lstrcatW(lpNameBuffer, commaW);
lstrcatW(lpNameBuffer, ComputersW); lstrcatW(lpNameBuffer, ComputersW);
lstrcatW(lpNameBuffer, commaW); if (domainInfo->DnsDomainName.Buffer)
lstrcatW(lpNameBuffer, dcW);
lstrcatW(lpNameBuffer, domainInfo->DnsDomainName.Buffer);
if (suffix)
{ {
lstrcatW(lpNameBuffer, commaW); lstrcatW(lpNameBuffer, commaW);
lstrcatW(lpNameBuffer, dcW); lstrcatW(lpNameBuffer, dcW);
lstrcatW(lpNameBuffer, suffix); lstrcatW(lpNameBuffer, domainInfo->DnsDomainName.Buffer);
if (suffix)
{
lstrcatW(lpNameBuffer, commaW);
lstrcatW(lpNameBuffer, dcW);
lstrcatW(lpNameBuffer, suffix);
}
} }
status = TRUE; status = TRUE;
} }
......
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