Module: wine Branch: master Commit: a63612045d812ed38af4153e072a8ffb90e3823d URL: https://gitlab.winehq.org/wine/wine/-/commit/a63612045d812ed38af4153e072a8ff...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed May 3 14:56:34 2023 +0200
ntdll/tests: Add some RtlValidSecurityDescriptor() tests.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
dlls/advapi32/tests/security.c | 29 +++++++++++++++++++++++++++++ dlls/ntdll/tests/rtl.c | 24 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index 8b4a868ee11..bef0d2d5f2c 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -8560,6 +8560,34 @@ static void test_group_as_file_owner(void) ok(ret, "got error %lu\n", GetLastError()); }
+static void test_IsValidSecurityDescriptor(void) +{ + SECURITY_DESCRIPTOR *sd; + BOOL ret; + + SetLastError(0xdeadbeef); + ret = IsValidSecurityDescriptor(NULL); + ok(!ret, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_SECURITY_DESCR, "Unexpected error %ld.\n", GetLastError()); + + sd = calloc(1, SECURITY_DESCRIPTOR_MIN_LENGTH); + + SetLastError(0xdeadbeef); + ret = IsValidSecurityDescriptor(sd); + ok(!ret, "Unexpected return value %d.\n", ret); + ok(GetLastError() == ERROR_INVALID_SECURITY_DESCR, "Unexpected error %ld.\n", GetLastError()); + + ret = InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION); + ok(ret, "Unexpected return value %d, error %ld.\n", ret, GetLastError()); + + SetLastError(0xdeadbeef); + ret = IsValidSecurityDescriptor(sd); + ok(ret, "Unexpected return value %d.\n", ret); + ok(GetLastError() == 0xdeadbeef, "Unexpected error %ld.\n", GetLastError()); + + free(sd); +} + START_TEST(security) { init(); @@ -8629,6 +8657,7 @@ START_TEST(security) test_GetKernelObjectSecurity(); test_elevation(); test_group_as_file_owner(); + test_IsValidSecurityDescriptor();
/* Must be the last test, modifies process token */ test_token_security_descriptor(); diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 269d26c8a16..b1ef492627a 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -3625,6 +3625,29 @@ static void test_RtlInitializeSid(void) ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %#lx.\n", status); }
+static void test_RtlValidSecurityDescriptor(void) +{ + SECURITY_DESCRIPTOR *sd; + NTSTATUS status; + BOOLEAN ret; + + ret = RtlValidSecurityDescriptor(NULL); + ok(!ret, "Unexpected return value %d.\n", ret); + + sd = calloc(1, SECURITY_DESCRIPTOR_MIN_LENGTH); + + ret = RtlValidSecurityDescriptor(sd); + ok(!ret, "Unexpected return value %d.\n", ret); + + status = RtlCreateSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION); + ok(!status, "Unexpected return value %#lx.\n", status); + + ret = RtlValidSecurityDescriptor(sd); + ok(ret, "Unexpected return value %d.\n", ret); + + free(sd); +} + START_TEST(rtl) { InitFunctionPtrs(); @@ -3670,4 +3693,5 @@ START_TEST(rtl) test_RtlDestroyHeap(); test_RtlFirstFreeAce(); test_RtlInitializeSid(); + test_RtlValidSecurityDescriptor(); }