mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[ADVAPI32]
* Apply Wine commit e57edfea by Paul Vriens: Skip leading spaces when parsing. * Update the related functions with Wine 1.7.27. CORE-8540 svn path=/trunk/; revision=65007
This commit is contained in:
parent
7a1f0bac68
commit
6d8f72bf65
1 changed files with 69 additions and 52 deletions
|
@ -2335,6 +2335,9 @@ static BYTE ParseAceStringType(LPCWSTR* StringAcl)
|
||||||
LPCWSTR szAcl = *StringAcl;
|
LPCWSTR szAcl = *StringAcl;
|
||||||
const ACEFLAG *lpaf = AceType;
|
const ACEFLAG *lpaf = AceType;
|
||||||
|
|
||||||
|
while (*szAcl == ' ')
|
||||||
|
szAcl++;
|
||||||
|
|
||||||
while (lpaf->wstr &&
|
while (lpaf->wstr &&
|
||||||
(len = strlenW(lpaf->wstr)) &&
|
(len = strlenW(lpaf->wstr)) &&
|
||||||
strncmpW(lpaf->wstr, szAcl, len))
|
strncmpW(lpaf->wstr, szAcl, len))
|
||||||
|
@ -2343,7 +2346,7 @@ static BYTE ParseAceStringType(LPCWSTR* StringAcl)
|
||||||
if (!lpaf->wstr)
|
if (!lpaf->wstr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*StringAcl += len;
|
*StringAcl = szAcl + len;
|
||||||
return lpaf->value;
|
return lpaf->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2369,6 +2372,9 @@ static BYTE ParseAceStringFlags(LPCWSTR* StringAcl)
|
||||||
BYTE flags = 0;
|
BYTE flags = 0;
|
||||||
LPCWSTR szAcl = *StringAcl;
|
LPCWSTR szAcl = *StringAcl;
|
||||||
|
|
||||||
|
while (*szAcl == ' ')
|
||||||
|
szAcl++;
|
||||||
|
|
||||||
while (*szAcl != ';')
|
while (*szAcl != ';')
|
||||||
{
|
{
|
||||||
const ACEFLAG *lpaf = AceFlags;
|
const ACEFLAG *lpaf = AceFlags;
|
||||||
|
@ -2381,7 +2387,7 @@ static BYTE ParseAceStringFlags(LPCWSTR* StringAcl)
|
||||||
if (!lpaf->wstr)
|
if (!lpaf->wstr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
flags |= lpaf->value;
|
flags |= lpaf->value;
|
||||||
szAcl += len;
|
szAcl += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2399,19 +2405,22 @@ static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
|
||||||
DWORD rights = 0;
|
DWORD rights = 0;
|
||||||
LPCWSTR szAcl = *StringAcl;
|
LPCWSTR szAcl = *StringAcl;
|
||||||
|
|
||||||
|
while (*szAcl == ' ')
|
||||||
|
szAcl++;
|
||||||
|
|
||||||
if ((*szAcl == '0') && (*(szAcl + 1) == 'x'))
|
if ((*szAcl == '0') && (*(szAcl + 1) == 'x'))
|
||||||
{
|
{
|
||||||
LPCWSTR p = szAcl;
|
LPCWSTR p = szAcl;
|
||||||
|
|
||||||
while (*p && *p != ';')
|
while (*p && *p != ';')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (p - szAcl <= 10 /* 8 hex digits + "0x" */ )
|
if (p - szAcl <= 10 /* 8 hex digits + "0x" */ )
|
||||||
{
|
{
|
||||||
rights = strtoulW(szAcl, NULL, 16);
|
rights = strtoulW(szAcl, NULL, 16);
|
||||||
szAcl = p;
|
szAcl = p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl, p - szAcl));
|
WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl, p - szAcl));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2421,16 +2430,16 @@ static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
|
||||||
const ACEFLAG *lpaf = AceRights;
|
const ACEFLAG *lpaf = AceRights;
|
||||||
|
|
||||||
while (lpaf->wstr &&
|
while (lpaf->wstr &&
|
||||||
(len = strlenW(lpaf->wstr)) &&
|
(len = strlenW(lpaf->wstr)) &&
|
||||||
strncmpW(lpaf->wstr, szAcl, len))
|
strncmpW(lpaf->wstr, szAcl, len))
|
||||||
{
|
{
|
||||||
lpaf++;
|
lpaf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lpaf->wstr)
|
if (!lpaf->wstr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rights |= lpaf->value;
|
rights |= lpaf->value;
|
||||||
szAcl += len;
|
szAcl += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2445,11 +2454,8 @@ static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
|
||||||
*
|
*
|
||||||
* dacl_flags(string_ace1)(string_ace2)... (string_acen)
|
* dacl_flags(string_ace1)(string_ace2)... (string_acen)
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
|
||||||
ParseStringAclToAcl(LPCWSTR StringAcl,
|
PACL pAcl, LPDWORD cBytes)
|
||||||
LPDWORD lpdwFlags,
|
|
||||||
PACL pAcl,
|
|
||||||
LPDWORD cBytes)
|
|
||||||
{
|
{
|
||||||
DWORD val;
|
DWORD val;
|
||||||
DWORD sidlen;
|
DWORD sidlen;
|
||||||
|
@ -2457,11 +2463,12 @@ ParseStringAclToAcl(LPCWSTR StringAcl,
|
||||||
DWORD acesize = 0;
|
DWORD acesize = 0;
|
||||||
DWORD acecount = 0;
|
DWORD acecount = 0;
|
||||||
PACCESS_ALLOWED_ACE pAce = NULL; /* pointer to current ACE */
|
PACCESS_ALLOWED_ACE pAce = NULL; /* pointer to current ACE */
|
||||||
|
DWORD error = ERROR_INVALID_ACL;
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(StringAcl));
|
TRACE("%s\n", debugstr_w(StringAcl));
|
||||||
|
|
||||||
if (!StringAcl)
|
if (!StringAcl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (pAcl) /* pAce is only useful if we're setting values */
|
if (pAcl) /* pAce is only useful if we're setting values */
|
||||||
pAce = (PACCESS_ALLOWED_ACE) (pAcl + 1);
|
pAce = (PACCESS_ALLOWED_ACE) (pAcl + 1);
|
||||||
|
@ -2476,29 +2483,34 @@ ParseStringAclToAcl(LPCWSTR StringAcl,
|
||||||
|
|
||||||
/* Parse ACE type */
|
/* Parse ACE type */
|
||||||
val = ParseAceStringType(&StringAcl);
|
val = ParseAceStringType(&StringAcl);
|
||||||
if (pAce)
|
if (pAce)
|
||||||
pAce->Header.AceType = (BYTE) val;
|
pAce->Header.AceType = (BYTE) val;
|
||||||
if (*StringAcl != ';')
|
if (*StringAcl != ';')
|
||||||
|
{
|
||||||
|
error = RPC_S_INVALID_STRING_UUID;
|
||||||
goto lerr;
|
goto lerr;
|
||||||
|
}
|
||||||
StringAcl++;
|
StringAcl++;
|
||||||
|
|
||||||
/* Parse ACE flags */
|
/* Parse ACE flags */
|
||||||
val = ParseAceStringFlags(&StringAcl);
|
val = ParseAceStringFlags(&StringAcl);
|
||||||
if (pAce)
|
if (pAce)
|
||||||
pAce->Header.AceFlags = (BYTE) val;
|
pAce->Header.AceFlags = (BYTE) val;
|
||||||
if (*StringAcl != ';')
|
if (*StringAcl != ';')
|
||||||
goto lerr;
|
goto lerr;
|
||||||
StringAcl++;
|
StringAcl++;
|
||||||
|
|
||||||
/* Parse ACE rights */
|
/* Parse ACE rights */
|
||||||
val = ParseAceStringRights(&StringAcl);
|
val = ParseAceStringRights(&StringAcl);
|
||||||
if (pAce)
|
if (pAce)
|
||||||
pAce->Mask = val;
|
pAce->Mask = val;
|
||||||
if (*StringAcl != ';')
|
if (*StringAcl != ';')
|
||||||
goto lerr;
|
goto lerr;
|
||||||
StringAcl++;
|
StringAcl++;
|
||||||
|
|
||||||
/* Parse ACE object guid */
|
/* Parse ACE object guid */
|
||||||
|
while (*StringAcl == ' ')
|
||||||
|
StringAcl++;
|
||||||
if (*StringAcl != ';')
|
if (*StringAcl != ';')
|
||||||
{
|
{
|
||||||
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
||||||
|
@ -2507,6 +2519,8 @@ ParseStringAclToAcl(LPCWSTR StringAcl,
|
||||||
StringAcl++;
|
StringAcl++;
|
||||||
|
|
||||||
/* Parse ACE inherit object guid */
|
/* Parse ACE inherit object guid */
|
||||||
|
while (*StringAcl == ' ')
|
||||||
|
StringAcl++;
|
||||||
if (*StringAcl != ';')
|
if (*StringAcl != ';')
|
||||||
{
|
{
|
||||||
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
||||||
|
@ -2516,10 +2530,10 @@ ParseStringAclToAcl(LPCWSTR StringAcl,
|
||||||
|
|
||||||
/* Parse ACE account sid */
|
/* Parse ACE account sid */
|
||||||
if (ParseStringSidToSid(StringAcl, pAce ? &pAce->SidStart : NULL, &sidlen))
|
if (ParseStringSidToSid(StringAcl, pAce ? &pAce->SidStart : NULL, &sidlen))
|
||||||
{
|
{
|
||||||
while (*StringAcl && *StringAcl != ')')
|
while (*StringAcl && *StringAcl != ')')
|
||||||
StringAcl++;
|
StringAcl++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*StringAcl != ')')
|
if (*StringAcl != ')')
|
||||||
goto lerr;
|
goto lerr;
|
||||||
|
@ -2554,7 +2568,7 @@ ParseStringAclToAcl(LPCWSTR StringAcl,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
lerr:
|
lerr:
|
||||||
SetLastError(ERROR_INVALID_ACL);
|
SetLastError(error);
|
||||||
WARN("Invalid ACE string format\n");
|
WARN("Invalid ACE string format\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2563,10 +2577,10 @@ lerr:
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ParseStringSecurityDescriptorToSecurityDescriptor
|
* ParseStringSecurityDescriptorToSecurityDescriptor
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
|
||||||
ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescriptor,
|
LPCWSTR StringSecurityDescriptor,
|
||||||
SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
|
SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
|
||||||
LPDWORD cBytes)
|
LPDWORD cBytes)
|
||||||
{
|
{
|
||||||
BOOL bret = FALSE;
|
BOOL bret = FALSE;
|
||||||
WCHAR toktype;
|
WCHAR toktype;
|
||||||
|
@ -2580,25 +2594,28 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
if (SecurityDescriptor)
|
if (SecurityDescriptor)
|
||||||
lpNext = (LPBYTE)(SecurityDescriptor + 1);
|
lpNext = (LPBYTE)(SecurityDescriptor + 1);
|
||||||
|
|
||||||
|
while (*StringSecurityDescriptor == ' ')
|
||||||
|
StringSecurityDescriptor++;
|
||||||
|
|
||||||
while (*StringSecurityDescriptor)
|
while (*StringSecurityDescriptor)
|
||||||
{
|
{
|
||||||
toktype = *StringSecurityDescriptor;
|
toktype = *StringSecurityDescriptor;
|
||||||
|
|
||||||
/* Expect char identifier followed by ':' */
|
/* Expect char identifier followed by ':' */
|
||||||
StringSecurityDescriptor++;
|
StringSecurityDescriptor++;
|
||||||
if (*StringSecurityDescriptor != ':')
|
if (*StringSecurityDescriptor != ':')
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
goto lend;
|
goto lend;
|
||||||
}
|
}
|
||||||
StringSecurityDescriptor++;
|
StringSecurityDescriptor++;
|
||||||
|
|
||||||
/* Extract token */
|
/* Extract token */
|
||||||
lptoken = StringSecurityDescriptor;
|
lptoken = StringSecurityDescriptor;
|
||||||
while (*lptoken && *lptoken != ':')
|
while (*lptoken && *lptoken != ':')
|
||||||
lptoken++;
|
lptoken++;
|
||||||
|
|
||||||
if (*lptoken)
|
if (*lptoken)
|
||||||
lptoken--;
|
lptoken--;
|
||||||
|
|
||||||
len = lptoken - StringSecurityDescriptor;
|
len = lptoken - StringSecurityDescriptor;
|
||||||
|
@ -2606,7 +2623,7 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
tok[len] = 0;
|
tok[len] = 0;
|
||||||
|
|
||||||
switch (toktype)
|
switch (toktype)
|
||||||
{
|
{
|
||||||
case 'O':
|
case 'O':
|
||||||
{
|
{
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
|
@ -2620,7 +2637,7 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
lpNext += bytes; /* Advance to next token */
|
lpNext += bytes; /* Advance to next token */
|
||||||
}
|
}
|
||||||
|
|
||||||
*cBytes += bytes;
|
*cBytes += bytes;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2638,13 +2655,13 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
lpNext += bytes; /* Advance to next token */
|
lpNext += bytes; /* Advance to next token */
|
||||||
}
|
}
|
||||||
|
|
||||||
*cBytes += bytes;
|
*cBytes += bytes;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
|
|
||||||
|
@ -2656,11 +2673,11 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
SecurityDescriptor->Control |= SE_DACL_PRESENT | flags;
|
SecurityDescriptor->Control |= SE_DACL_PRESENT | flags;
|
||||||
SecurityDescriptor->Dacl = lpNext - (LPBYTE)SecurityDescriptor;
|
SecurityDescriptor->Dacl = lpNext - (LPBYTE)SecurityDescriptor;
|
||||||
lpNext += bytes; /* Advance to next token */
|
lpNext += bytes; /* Advance to next token */
|
||||||
}
|
}
|
||||||
|
|
||||||
*cBytes += bytes;
|
*cBytes += bytes;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
|
@ -2676,18 +2693,18 @@ ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescript
|
||||||
SecurityDescriptor->Control |= SE_SACL_PRESENT | flags;
|
SecurityDescriptor->Control |= SE_SACL_PRESENT | flags;
|
||||||
SecurityDescriptor->Sacl = lpNext - (LPBYTE)SecurityDescriptor;
|
SecurityDescriptor->Sacl = lpNext - (LPBYTE)SecurityDescriptor;
|
||||||
lpNext += bytes; /* Advance to next token */
|
lpNext += bytes; /* Advance to next token */
|
||||||
}
|
}
|
||||||
|
|
||||||
*cBytes += bytes;
|
*cBytes += bytes;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("Unknown token\n");
|
FIXME("Unknown token\n");
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
goto lend;
|
goto lend;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringSecurityDescriptor = lptoken;
|
StringSecurityDescriptor = lptoken;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue