ConvertStringSecurityDescriptorToSecurityDescriptor - more tests (pass)
Paul Bryan Roberts
pbronline-wine at yahoo.co.uk
Mon Oct 13 16:02:06 CDT 2008
---
dlls/advapi32/security.c | 8 +++++-
dlls/advapi32/tests/security.c | 47 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index ca26217..716cc5c 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -3829,6 +3829,7 @@ static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
return TRUE;
lerr:
+ SetLastError(ERROR_INVALID_ACL);
WARN("Invalid ACE string format\n");
return FALSE;
}
@@ -4021,6 +4022,11 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
goto lend;
}
+ else if (!StringSecurityDescriptor || !SecurityDescriptor)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto lend;
+ }
else if (StringSDRevision != SID_REVISION)
{
SetLastError(ERROR_UNKNOWN_REVISION);
@@ -4472,7 +4478,6 @@ BOOL WINAPI ConvertStringSidToSidW(LPCWSTR StringSid, PSID* Sid)
if (!bret)
LocalFree(*Sid);
}
- TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
return bret;
}
@@ -4498,7 +4503,6 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
bret = ConvertStringSidToSidW(wStringSid, Sid);
HeapFree(GetProcessHeap(), 0, wStringSid);
}
- TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
return bret;
}
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 99dbce8..5fcb539 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -81,6 +81,8 @@ typedef BOOL (WINAPI *fnConvertSidToStringSidA)( PSID pSid, LPSTR *str );
typedef BOOL (WINAPI *fnConvertStringSidToSidA)( LPCSTR str, PSID pSid );
static BOOL (WINAPI *pConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR, DWORD,
PSECURITY_DESCRIPTOR*, PULONG );
+static BOOL (WINAPI *pConvertStringSecurityDescriptorToSecurityDescriptorW)(LPCWSTR, DWORD,
+ PSECURITY_DESCRIPTOR*, PULONG );
static BOOL (WINAPI *pConvertSecurityDescriptorToStringSecurityDescriptorA)(PSECURITY_DESCRIPTOR, DWORD,
SECURITY_INFORMATION, LPSTR *, PULONG );
typedef BOOL (WINAPI *fnGetFileSecurityA)(LPCSTR, SECURITY_INFORMATION,
@@ -144,6 +146,8 @@ static void init(void)
pAddAuditAccessAceEx = (void *)GetProcAddress(hmod, "AddAuditAccessAceEx");
pConvertStringSecurityDescriptorToSecurityDescriptorA =
(void *)GetProcAddress(hmod, "ConvertStringSecurityDescriptorToSecurityDescriptorA" );
+ pConvertStringSecurityDescriptorToSecurityDescriptorW =
+ (void *)GetProcAddress(hmod, "ConvertStringSecurityDescriptorToSecurityDescriptorW" );
pConvertSecurityDescriptorToStringSecurityDescriptorA =
(void *)GetProcAddress(hmod, "ConvertSecurityDescriptorToStringSecurityDescriptorA" );
pCreateWellKnownSid = (fnCreateWellKnownSid)GetProcAddress( hmod, "CreateWellKnownSid" );
@@ -2175,6 +2179,7 @@ static void test_ConvertStringSecurityDescriptor(void)
{
BOOL ret;
PSECURITY_DESCRIPTOR pSD;
+ static const WCHAR Blank[] = { 0 };
if (!pConvertStringSecurityDescriptorToSecurityDescriptorA)
{
@@ -2255,11 +2260,51 @@ static void test_ConvertStringSecurityDescriptor(void)
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;ROB;;;WD)", SDDL_REVISION_1, &pSD, NULL);
- todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_ACL,
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_ACL instead of %d\n",
GetLastError());
+ /* test behaviour with NULL parameters */
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
+ NULL, 0xdeadbeef, &pSD, NULL);
+ todo_wine
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
+ GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorW(
+ NULL, 0xdeadbeef, &pSD, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
+ GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
+ "D:(A;;ROB;;;WD)", 0xdeadbeef, NULL, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
+ GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
+ "D:(A;;ROB;;;WD)", SDDL_REVISION_1, NULL, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+ "ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
+ GetLastError());
+
+ /* test behaviour with empty strings */
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
+ "", SDDL_REVISION_1, &pSD, NULL);
+ ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = pConvertStringSecurityDescriptorToSecurityDescriptorW(
+ Blank, SDDL_REVISION_1, &pSD, NULL);
+ ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
+
/* test ACE string SID */
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
--
1.5.4.3
--------------010602040106080802020306--
More information about the wine-patches
mailing list