msi: Allocate token information buffer dynamically.

This commit is contained in:
Hans Leidekker 2009-03-27 13:41:35 +01:00 committed by Alexandre Julliard
parent f0d1d61d3b
commit 4365b34838
1 changed files with 8 additions and 4 deletions

View File

@ -516,15 +516,19 @@ static void create_test_guid(LPSTR prodcode, LPSTR squashed)
static void get_user_sid(LPSTR *usersid) static void get_user_sid(LPSTR *usersid)
{ {
HANDLE token; HANDLE token;
BYTE buf[1024];
DWORD size; DWORD size;
PTOKEN_USER user; PTOKEN_USER user;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
size = sizeof(buf);
GetTokenInformation(token, TokenUser, buf, size, &size); size = 0;
user = (PTOKEN_USER)buf; GetTokenInformation(token, TokenUser, NULL, size, &size);
user = HeapAlloc(GetProcessHeap(), 0, size);
GetTokenInformation(token, TokenUser, user, size, &size);
pConvertSidToStringSidA(user->User.Sid, usersid); pConvertSidToStringSidA(user->User.Sid, usersid);
HeapFree(GetProcessHeap(), 0, user);
CloseHandle(token); CloseHandle(token);
} }