ntdll: Allow NULL return length argument in NtAdjustPrivilegesToken().
This commit is contained in:
parent
e810a58494
commit
fd65b0a1c3
|
@ -611,8 +611,9 @@ AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
TRACE("\n");
|
TRACE("(%p %d %p %d %p %p)\n", TokenHandle, DisableAllPrivileges, NewState, BufferLength,
|
||||||
|
PreviousState, ReturnLength);
|
||||||
|
|
||||||
status = NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges,
|
status = NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges,
|
||||||
NewState, BufferLength, PreviousState,
|
NewState, BufferLength, PreviousState,
|
||||||
ReturnLength);
|
ReturnLength);
|
||||||
|
|
|
@ -4760,6 +4760,41 @@ static void test_default_dacl_owner_sid(void)
|
||||||
CloseHandle( handle );
|
CloseHandle( handle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_AdjustTokenPrivileges(void)
|
||||||
|
{
|
||||||
|
TOKEN_PRIVILEGES tp, prev;
|
||||||
|
HANDLE token;
|
||||||
|
DWORD len;
|
||||||
|
LUID luid;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!LookupPrivilegeValueA(NULL, SE_BACKUP_NAME, &luid))
|
||||||
|
{
|
||||||
|
CloseHandle(token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp.PrivilegeCount = 1;
|
||||||
|
tp.Privileges[0].Luid = luid;
|
||||||
|
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
|
||||||
|
len = 0xdeadbeef;
|
||||||
|
ret = AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, &len);
|
||||||
|
ok(ret, "got %d\n", ret);
|
||||||
|
ok(len == 0xdeadbeef, "got length %d\n", len);
|
||||||
|
|
||||||
|
/* revert */
|
||||||
|
tp.PrivilegeCount = 1;
|
||||||
|
tp.Privileges[0].Luid = luid;
|
||||||
|
tp.Privileges[0].Attributes = 0;
|
||||||
|
AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &prev, NULL);
|
||||||
|
|
||||||
|
CloseHandle(token);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(security)
|
START_TEST(security)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -4800,4 +4835,5 @@ START_TEST(security)
|
||||||
test_CreateRestrictedToken();
|
test_CreateRestrictedToken();
|
||||||
test_TokenIntegrityLevel();
|
test_TokenIntegrityLevel();
|
||||||
test_default_dacl_owner_sid();
|
test_default_dacl_owner_sid();
|
||||||
|
test_AdjustTokenPrivileges();
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ NTSTATUS WINAPI NtAdjustPrivilegesToken(
|
||||||
ret = wine_server_call( req );
|
ret = wine_server_call( req );
|
||||||
if (PreviousState)
|
if (PreviousState)
|
||||||
{
|
{
|
||||||
*ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
|
if (ReturnLength) *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
|
||||||
PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
|
PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue