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

This commit is contained in:
Paul Bryan Roberts 2008-10-18 21:28:39 +01:00 committed by Alexandre Julliard
parent a3e0bc10bb
commit a37512ee63
1 changed files with 22 additions and 1 deletions

View File

@ -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
*peUse = ACCOUNT_SIDS[i].name_use; *peUse = ACCOUNT_SIDS[i].name_use;
} }
HeapFree(GetProcessHeap(), 0, pSid);
return ret; return ret;
} }
} }