Hans Leidekker : advapi32: Fix parsing empty DACL/ SACL security descriptor strings.
Alexandre Julliard
julliard at winehq.org
Fri Nov 17 16:02:18 CST 2017
Module: wine
Branch: master
Commit: 1d03ba7611644807af38be40af46e1b22d1dd9cd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1d03ba7611644807af38be40af46e1b22d1dd9cd
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Nov 17 15:56:58 2017 +0100
advapi32: Fix parsing empty DACL/SACL security descriptor strings.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/advapi32/security.c | 4 ++--
dlls/advapi32/tests/security.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index a762d5a..7281e01 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -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;
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 08d3705..e86fe21 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -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)
More information about the wine-cvs
mailing list