Paul Bryan Roberts : advapi32: ConvertStringSecurityDescriptorToSecurityDescriptor - more tests (pass).
Alexandre Julliard
julliard at winehq.org
Fri Oct 17 07:26:01 CDT 2008
Module: wine
Branch: master
Commit: 7e0932d627c34a25c630e743f28c1496a83eeddd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7e0932d627c34a25c630e743f28c1496a83eeddd
Author: Paul Bryan Roberts <pbronline-wine at yahoo.co.uk>
Date: Mon Oct 13 22:02:06 2008 +0100
advapi32: ConvertStringSecurityDescriptorToSecurityDescriptor - more tests (pass).
---
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 832e6fa..3c26654 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -3833,6 +3833,7 @@ static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
return TRUE;
lerr:
+ SetLastError(ERROR_INVALID_ACL);
WARN("Invalid ACE string format\n");
return FALSE;
}
@@ -4025,6 +4026,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);
@@ -4476,7 +4482,6 @@ BOOL WINAPI ConvertStringSidToSidW(LPCWSTR StringSid, PSID* Sid)
if (!bret)
LocalFree(*Sid);
}
- TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
return bret;
}
@@ -4502,7 +4507,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 45c8fd5..f0d7ade 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(
More information about the wine-cvs
mailing list