[TASKMGR] CachedGetUserFromSid(): Fix user name length on cache hit

This commit is contained in:
Serge Gautherie 2020-06-10 10:09:14 +02:00 committed by Mark Jansen
parent 353b544047
commit f91144364b

View file

@ -144,16 +144,16 @@ CachedGetUserFromSid(
if (EqualSid((PSID)&pEntry->Data, pSid)) if (EqualSid((PSID)&pEntry->Data, pSid))
{ {
wcsncpy(pUserName, pEntry->pszName, cwcUserName); wcsncpy(pUserName, pEntry->pszName, cwcUserName);
*pcwcUserName = cwcUserName; *pcwcUserName = wcslen(pUserName);
return; return;
} }
} }
/* We didn't find the SID in the list, get the name conventional */ /* We didn't find the SID in the list, get the name conventional */
SidToUserName(pSid, pUserName, cwcUserName); SidToUserName(pSid, pUserName, cwcUserName);
*pcwcUserName = wcslen(pUserName);
/* Allocate a new entry */ /* Allocate a new entry */
*pcwcUserName = wcslen(pUserName);
cwcUserName = *pcwcUserName + 1; cwcUserName = *pcwcUserName + 1;
cbSid = GetLengthSid(pSid); cbSid = GetLengthSid(pSid);
pEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(SIDTOUSERNAME) + cbSid + cwcUserName * sizeof(WCHAR)); pEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(SIDTOUSERNAME) + cbSid + cwcUserName * sizeof(WCHAR));