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

Alexandre Julliard julliard at winehq.org
Tue Mar 27 16:08:50 CDT 2018


Module: wine
Branch: master
Commit: d7430abd406d1f298acb9b2e5a397e11e448f304
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d7430abd406d1f298acb9b2e5a397e11e448f304

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Mar 27 17:06:12 2018 +0800

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: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/secur32/secur32.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index bece2b7..9240c10 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -921,7 +921,9 @@ BOOLEAN WINAPI GetComputerObjectNameA(
     BOOLEAN rc;
     LPWSTR bufferW = NULL;
     ULONG sizeW = *nSize;
+
     TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
+
     if (lpNameBuffer) {
         bufferW = heap_alloc(sizeW * sizeof(WCHAR));
         if (bufferW == NULL) {
@@ -952,6 +954,7 @@ BOOLEAN WINAPI GetComputerObjectNameW(
     PPOLICY_DNS_DOMAIN_INFO domainInfo;
     NTSTATUS ntStatus;
     BOOLEAN status;
+
     TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
 
     if (NameFormat == NameUnknown)
@@ -1000,8 +1003,13 @@ BOOLEAN WINAPI GetComputerObjectNameW(
                     {
                         WCHAR bs[] = { '\\', 0 };
                         WCHAR ds[] = { '$', 0 };
-                        lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
-                        lstrcatW(lpNameBuffer, bs);
+                        if (domainInfo->Name.Buffer)
+                        {
+                            lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
+                            lstrcatW(lpNameBuffer, bs);
+                        }
+                        else
+                            *lpNameBuffer = 0;
                         lstrcatW(lpNameBuffer, name);
                         lstrcatW(lpNameBuffer, ds);
                         status = TRUE;
@@ -1038,13 +1046,18 @@ BOOLEAN WINAPI GetComputerObjectNameW(
             }
 
             len = strlenW(cnW) + size + 1 + strlenW(ComputersW) + 1 + strlenW(dcW);
-            suffix = strrchrW(domainInfo->DnsDomainName.Buffer, '.');
-            if (suffix)
+            if (domainInfo->DnsDomainName.Buffer)
             {
-                *suffix++ = 0;
-                len += 1 + strlenW(dcW) + strlenW(suffix);
+                suffix = strrchrW(domainInfo->DnsDomainName.Buffer, '.');
+                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)
             {
@@ -1052,14 +1065,17 @@ BOOLEAN WINAPI GetComputerObjectNameW(
                 lstrcatW(lpNameBuffer, name);
                 lstrcatW(lpNameBuffer, commaW);
                 lstrcatW(lpNameBuffer, ComputersW);
-                lstrcatW(lpNameBuffer, commaW);
-                lstrcatW(lpNameBuffer, dcW);
-                lstrcatW(lpNameBuffer, domainInfo->DnsDomainName.Buffer);
-                if (suffix)
+                if (domainInfo->DnsDomainName.Buffer)
                 {
                     lstrcatW(lpNameBuffer, commaW);
                     lstrcatW(lpNameBuffer, dcW);
-                    lstrcatW(lpNameBuffer, suffix);
+                    lstrcatW(lpNameBuffer, domainInfo->DnsDomainName.Buffer);
+                    if (suffix)
+                    {
+                        lstrcatW(lpNameBuffer, commaW);
+                        lstrcatW(lpNameBuffer, dcW);
+                        lstrcatW(lpNameBuffer, suffix);
+                    }
                 }
                 status = TRUE;
             }




More information about the wine-cvs mailing list