Author: ekohl
Date: Sun Apr 10 15:42:55 2011
New Revision: 51313

URL: http://svn.reactos.org/svn/reactos?rev=51313&view=rev
Log:
[NETAPI32]
NetUserModalsGet failed if the domain SID returned by LsaQueryInformationPolicy 
was NULL. Handle the NULL SID case correctly.
See issue #6102 for more details.

Modified:
    trunk/reactos/dll/win32/netapi32/access.c

Modified: trunk/reactos/dll/win32/netapi32/access.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/access.c?rev=51313&r1=51312&r2=51313&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netapi32/access.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netapi32/access.c [iso-8859-1] Sun Apr 10 15:42:55 
2011
@@ -793,7 +793,7 @@
             PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo;
             NTSTATUS ntStatus;
             PSID domainIdentifier = NULL;
-            int domainNameLen;
+            int domainNameLen, domainIdLen;
 
             ZeroMemory(&objectAttributes, sizeof(objectAttributes));
             objectAttributes.Length = sizeof(objectAttributes);
@@ -820,11 +820,12 @@
             }
 
             domainIdentifier = domainInfo->DomainSid;
+            domainIdLen = (domainIdentifier) ? GetLengthSid(domainIdentifier) 
: 0;
             domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1;
             LsaClose(policyHandle);
 
             ntStatus = NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2) +
-                                            GetLengthSid(domainIdentifier) +
+                                            domainIdLen +
                                             domainNameLen * sizeof(WCHAR),
                                             (LPVOID *)pbuffer);
 
@@ -836,15 +837,16 @@
             }
 
             umi = (USER_MODALS_INFO_2 *) *pbuffer;
-            umi->usrmod2_domain_id = *pbuffer + sizeof(USER_MODALS_INFO_2);
+            umi->usrmod2_domain_id = (domainIdLen > 0) ? (*pbuffer + 
sizeof(USER_MODALS_INFO_2)) : NULL;
             umi->usrmod2_domain_name = (LPWSTR)(*pbuffer +
-                sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier));
+                sizeof(USER_MODALS_INFO_2) + domainIdLen);
 
             lstrcpynW(umi->usrmod2_domain_name,
                       domainInfo->DomainName.Buffer,
                       domainNameLen);
-            CopySid(GetLengthSid(domainIdentifier), umi->usrmod2_domain_id,
-                    domainIdentifier);
+            if (domainIdLen > 0)
+                CopySid(GetLengthSid(domainIdentifier), umi->usrmod2_domain_id,
+                        domainIdentifier);
 
             LsaFreeMemory(domainInfo);
 


Reply via email to