Commit a37512ee authored by Paul Bryan Roberts's avatar Paul Bryan Roberts Committed by Alexandre Julliard

advapi32: LookupAccountNameW() - use CreateWellKnownSid() properly.

parent a3e0bc10
...@@ -2536,7 +2536,26 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI ...@@ -2536,7 +2536,26 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
{ {
if (!strcmpW(lpAccountName, ACCOUNT_SIDS[i].account)) if (!strcmpW(lpAccountName, ACCOUNT_SIDS[i].account))
{ {
ret = CreateWellKnownSid(ACCOUNT_SIDS[i].type, NULL, Sid, cbSid); DWORD sidLen = SECURITY_MAX_SID_SIZE;
pSid = HeapAlloc(GetProcessHeap(), 0, sidLen);
ret = CreateWellKnownSid(ACCOUNT_SIDS[i].type, NULL, pSid, &sidLen);
if (ret)
{
if (*cbSid < sidLen)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
ret = FALSE;
}
else if (Sid)
{
CopySid(*cbSid, Sid, pSid);
}
*cbSid = sidLen;
}
domainName = ACCOUNT_SIDS[i].domain; domainName = ACCOUNT_SIDS[i].domain;
nameLen = strlenW(domainName); nameLen = strlenW(domainName);
...@@ -2559,6 +2578,8 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI ...@@ -2559,6 +2578,8 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
*peUse = ACCOUNT_SIDS[i].name_use; *peUse = ACCOUNT_SIDS[i].name_use;
} }
HeapFree(GetProcessHeap(), 0, pSid);
return ret; return ret;
} }
} }
......
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