LookupAccountNameW() use ACCOUNT_SIDS domain and name_use fields for well known SIDs

Paul Bryan Roberts pbronline-wine at yahoo.co.uk
Thu Sep 25 17:04:46 CDT 2008


---
 dlls/advapi32/security.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 9df5b45..b44354c 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -2532,11 +2532,30 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
     {
         if (!strcmpW(lpAccountName, ACCOUNT_SIDS[i].account))
         {
-            if (*cchReferencedDomainName)
-                *ReferencedDomainName = '\0';
-            *cchReferencedDomainName = 0;
-            *peUse = SidTypeWellKnownGroup;
-            return CreateWellKnownSid(ACCOUNT_SIDS[i].type, NULL, Sid, cbSid);
+            ret = CreateWellKnownSid(ACCOUNT_SIDS[i].type, NULL, Sid, cbSid);
+
+            domainName = ACCOUNT_SIDS[i].domain;
+            nameLen = strlenW(domainName);
+
+            if (*cchReferencedDomainName <= nameLen && ReferencedDomainName)
+            {
+                SetLastError(ERROR_INSUFFICIENT_BUFFER);
+                nameLen += 1;
+                ret = FALSE;
+            }
+            else if (ReferencedDomainName && domainName)
+            {
+                strcpyW(ReferencedDomainName, domainName);
+            }
+
+            *cchReferencedDomainName = nameLen;
+
+            if (ret)
+            {
+                *peUse = ACCOUNT_SIDS[i].name_use;
+            }
+
+            return ret;
         }
     }
 
-- 
1.5.4.3


--------------060707050104090705010503--



More information about the wine-patches mailing list