From: Sebastian Lackner sebastian@fds-team.de
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/advapi32/tests/security.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index 6ef6c41..38508f1 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -7316,6 +7316,44 @@ static void test_GetExplicitEntriesFromAclW(void) HeapFree(GetProcessHeap(), 0, old_acl); }
+static void test_BuildSecurityDescriptorW(void) +{ + SECURITY_DESCRIPTOR old_sd, *new_sd, *rel_sd; + ULONG new_sd_size; + DWORD buf_size; + char buf[1024]; + BOOL success; + DWORD ret; + + InitializeSecurityDescriptor(&old_sd, SECURITY_DESCRIPTOR_REVISION); + + buf_size = sizeof(buf); + rel_sd = (SECURITY_DESCRIPTOR *)buf; + success = MakeSelfRelativeSD(&old_sd, rel_sd, &buf_size); + ok(success, "MakeSelfRelativeSD failed with %u\n", GetLastError()); + + new_sd = NULL; + new_sd_size = 0; + ret = BuildSecurityDescriptorW(NULL, NULL, 0, NULL, 0, NULL, NULL, &new_sd_size, (void **)&new_sd); + ok(ret == ERROR_SUCCESS, "BuildSecurityDescriptor failed with %u\n", ret); + ok(new_sd != NULL, "expected new_sd != NULL\n"); + ok(new_sd->Sbz1 == old_sd.Sbz1, "expected %u got %u\n", new_sd->Sbz1, old_sd.Sbz1); + LocalFree(new_sd); + + new_sd = (void *)0xdeadbeef; + ret = BuildSecurityDescriptorW(NULL, NULL, 0, NULL, 0, NULL, &old_sd, &new_sd_size, (void **)&new_sd); + ok(ret == ERROR_INVALID_SECURITY_DESCR, "expected ERROR_INVALID_SECURITY_DESCR, got %u\n", ret); + ok(new_sd == (void *)0xdeadbeef, "expected new_sd == 0xdeadbeef, got %p\n", new_sd); + + new_sd = NULL; + new_sd_size = 0; + ret = BuildSecurityDescriptorW(NULL, NULL, 0, NULL, 0, NULL, rel_sd, &new_sd_size, (void **)&new_sd); + ok(ret == ERROR_SUCCESS, "BuildSecurityDescriptor failed with %u\n", ret); + ok(new_sd != NULL, "expected new_sd != NULL\n"); + ok(new_sd->Sbz1 == old_sd.Sbz1, "expected %u got %u\n", new_sd->Sbz1, old_sd.Sbz1); + LocalFree(new_sd); +} + START_TEST(security) { init(); @@ -7370,6 +7408,7 @@ START_TEST(security) test_maximum_allowed(); test_token_label(); test_GetExplicitEntriesFromAclW(); + test_BuildSecurityDescriptorW();
/* Must be the last test, modifies process token */ test_token_security_descriptor();