Commit 1d03ba76 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

advapi32: Fix parsing empty DACL/SACL security descriptor strings.

parent f9475469
......@@ -4314,7 +4314,7 @@ static DWORD ParseAclStringFlags(LPCWSTR* StringAcl)
DWORD flags = 0;
LPCWSTR szAcl = *StringAcl;
while (*szAcl != '(')
while (*szAcl && *szAcl != '(')
{
if (*szAcl == 'P')
{
......@@ -4625,7 +4625,7 @@ static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
pAcl->AclRevision = ACL_REVISION;
pAcl->Sbz1 = 0;
pAcl->AclSize = length;
pAcl->AceCount = acecount++;
pAcl->AceCount = acecount;
pAcl->Sbz2 = 0;
}
return TRUE;
......
......@@ -4101,6 +4101,8 @@ static void test_ConvertStringSecurityDescriptor(void)
PSECURITY_DESCRIPTOR pSD;
static const WCHAR Blank[] = { 0 };
unsigned int i;
ULONG size;
ACL *acl;
static const struct
{
const char *sidstring;
......@@ -4211,6 +4213,33 @@ static void test_ConvertStringSecurityDescriptor(void)
ok(ret || broken(!ret && GetLastError() == ERROR_INVALID_DATATYPE) /* win2k */,
"ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %u\n", GetLastError());
if (ret) LocalFree(pSD);
/* empty DACL */
size = 0;
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA("D:", SDDL_REVISION_1, &pSD, &size);
ok(ret, "unexpected error %u\n", GetLastError());
ok(size == sizeof(SECURITY_DESCRIPTOR_RELATIVE) + sizeof(ACL), "got %u\n", size);
acl = (ACL *)((char *)pSD + sizeof(SECURITY_DESCRIPTOR_RELATIVE));
ok(acl->AclRevision == ACL_REVISION, "got %u\n", acl->AclRevision);
ok(!acl->Sbz1, "got %u\n", acl->Sbz1);
ok(acl->AclSize == sizeof(*acl), "got %u\n", acl->AclSize);
ok(!acl->AceCount, "got %u\n", acl->AceCount);
ok(!acl->Sbz2, "got %u\n", acl->Sbz2);
LocalFree(pSD);
/* empty SACL */
size = 0;
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA("S:", SDDL_REVISION_1, &pSD, &size);
ok(ret, "unexpected error %u\n", GetLastError());
ok(size == sizeof(SECURITY_DESCRIPTOR_RELATIVE) + sizeof(ACL), "got %u\n", size);
acl = (ACL *)((char *)pSD + sizeof(SECURITY_DESCRIPTOR_RELATIVE));
ok(!acl->Sbz1, "got %u\n", acl->Sbz1);
ok(acl->AclSize == sizeof(*acl), "got %u\n", acl->AclSize);
ok(!acl->AceCount, "got %u\n", acl->AceCount);
ok(!acl->Sbz2, "got %u\n", acl->Sbz2);
LocalFree(pSD);
}
static void test_ConvertSecurityDescriptorToString(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment