Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
97fa635f
Commit
97fa635f
authored
Jan 11, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jan 12, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Convert the trustee name buffer based on trustee form in SetEntriesInAclA.
parent
d43cddcc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
140 additions
and
34 deletions
+140
-34
security.c
dlls/advapi32/security.c
+140
-34
No files found.
dlls/advapi32/security.c
View file @
97fa635f
...
@@ -3515,6 +3515,114 @@ BOOL WINAPI SetAclInformation( PACL pAcl, LPVOID pAclInformation,
...
@@ -3515,6 +3515,114 @@ BOOL WINAPI SetAclInformation( PACL pAcl, LPVOID pAclInformation,
return
TRUE
;
return
TRUE
;
}
}
DWORD
trustee_name_A_to_W
(
TRUSTEE_FORM
form
,
char
*
trustee_nameA
,
WCHAR
**
ptrustee_nameW
)
{
DWORD
len
;
switch
(
form
)
{
case
TRUSTEE_IS_NAME
:
{
WCHAR
*
wstr
=
NULL
;
if
(
trustee_nameA
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
trustee_nameA
,
-
1
,
NULL
,
0
);
if
(
!
(
wstr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
trustee_nameA
,
-
1
,
wstr
,
len
);
}
*
ptrustee_nameW
=
wstr
;
return
ERROR_SUCCESS
;
}
case
TRUSTEE_IS_OBJECTS_AND_NAME
:
{
OBJECTS_AND_NAME_A
*
objA
=
(
OBJECTS_AND_NAME_A
*
)
trustee_nameA
;
OBJECTS_AND_NAME_W
*
objW
=
NULL
;
if
(
objA
)
{
if
(
!
(
objW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
OBJECTS_AND_NAME_W
)
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
objW
->
ObjectsPresent
=
objA
->
ObjectsPresent
;
objW
->
ObjectType
=
objA
->
ObjectType
;
objW
->
ObjectTypeName
=
NULL
;
objW
->
InheritedObjectTypeName
=
NULL
;
objW
->
ptstrName
=
NULL
;
if
(
objA
->
ObjectTypeName
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
ObjectTypeName
,
-
1
,
NULL
,
0
);
if
(
!
(
objW
->
ObjectTypeName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
goto
error
;
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
ObjectTypeName
,
-
1
,
objW
->
ObjectTypeName
,
len
);
}
if
(
objA
->
InheritedObjectTypeName
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
InheritedObjectTypeName
,
-
1
,
NULL
,
0
);
if
(
!
(
objW
->
InheritedObjectTypeName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
goto
error
;
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
InheritedObjectTypeName
,
-
1
,
objW
->
InheritedObjectTypeName
,
len
);
}
if
(
objA
->
ptstrName
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
ptstrName
,
-
1
,
NULL
,
0
);
if
(
!
(
objW
->
ptstrName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
goto
error
;
MultiByteToWideChar
(
CP_ACP
,
0
,
objA
->
ptstrName
,
-
1
,
objW
->
ptstrName
,
len
);
}
}
*
ptrustee_nameW
=
(
WCHAR
*
)
objW
;
return
ERROR_SUCCESS
;
error:
HeapFree
(
GetProcessHeap
(),
0
,
objW
->
InheritedObjectTypeName
);
HeapFree
(
GetProcessHeap
(),
0
,
objW
->
ObjectTypeName
);
HeapFree
(
GetProcessHeap
(),
0
,
objW
);
return
ERROR_NOT_ENOUGH_MEMORY
;
}
/* These forms do not require conversion. */
case
TRUSTEE_IS_SID
:
case
TRUSTEE_IS_OBJECTS_AND_SID
:
*
ptrustee_nameW
=
(
WCHAR
*
)
trustee_nameA
;
return
ERROR_SUCCESS
;
default:
return
ERROR_INVALID_PARAMETER
;
}
}
void
free_trustee_name
(
TRUSTEE_FORM
form
,
WCHAR
*
trustee_nameW
)
{
switch
(
form
)
{
case
TRUSTEE_IS_NAME
:
HeapFree
(
GetProcessHeap
(),
0
,
trustee_nameW
);
break
;
case
TRUSTEE_IS_OBJECTS_AND_NAME
:
{
OBJECTS_AND_NAME_W
*
objW
=
(
OBJECTS_AND_NAME_W
*
)
trustee_nameW
;
if
(
objW
)
{
HeapFree
(
GetProcessHeap
(),
0
,
objW
->
ptstrName
);
HeapFree
(
GetProcessHeap
(),
0
,
objW
->
InheritedObjectTypeName
);
HeapFree
(
GetProcessHeap
(),
0
,
objW
->
ObjectTypeName
);
HeapFree
(
GetProcessHeap
(),
0
,
objW
);
}
break
;
}
/* Other forms did not require allocation, so no freeing is necessary. */
default:
break
;
}
}
/******************************************************************************
/******************************************************************************
* SetEntriesInAclA [ADVAPI32.@]
* SetEntriesInAclA [ADVAPI32.@]
*/
*/
...
@@ -3522,7 +3630,8 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
...
@@ -3522,7 +3630,8 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
PACL
OldAcl
,
PACL
*
NewAcl
)
PACL
OldAcl
,
PACL
*
NewAcl
)
{
{
DWORD
err
=
ERROR_SUCCESS
;
DWORD
err
=
ERROR_SUCCESS
;
PEXPLICIT_ACCESSW
pEntriesW
;
EXPLICIT_ACCESSW
*
pEntriesW
;
int
alloc_index
,
free_index
;
TRACE
(
"%d %p %p %p
\n
"
,
count
,
pEntries
,
OldAcl
,
NewAcl
);
TRACE
(
"%d %p %p %p
\n
"
,
count
,
pEntries
,
OldAcl
,
NewAcl
);
...
@@ -3532,46 +3641,43 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
...
@@ -3532,46 +3641,43 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
if
(
!
count
&&
!
OldAcl
)
if
(
!
count
&&
!
OldAcl
)
return
ERROR_SUCCESS
;
return
ERROR_SUCCESS
;
pEntriesW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
count
*
sizeof
(
EXPLICIT_ACCESSW
)
);
pEntriesW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
count
*
sizeof
(
EXPLICIT_ACCESSW
)
);
if
(
pEntriesW
)
if
(
!
pEntriesW
)
return
ERROR_NOT_ENOUGH_MEMORY
;
for
(
alloc_index
=
0
;
alloc_index
<
count
;
++
alloc_index
)
{
{
int
i
,
len
;
pEntriesW
[
alloc_index
].
grfAccessPermissions
=
pEntries
[
alloc_index
].
grfAccessPermissions
;
LPWSTR
wstr
=
NULL
;
pEntriesW
[
alloc_index
].
grfAccessMode
=
pEntries
[
alloc_index
].
grfAccessMode
;
PEXPLICIT_ACCESSW
ptrW
=
pEntriesW
;
pEntriesW
[
alloc_index
].
grfInheritance
=
pEntries
[
alloc_index
].
grfInheritance
;
PEXPLICIT_ACCESSA
ptrA
=
pEntries
;
pEntriesW
[
alloc_index
].
Trustee
.
pMultipleTrustee
=
NULL
;
/* currently not supported */
pEntriesW
[
alloc_index
].
Trustee
.
MultipleTrusteeOperation
=
pEntries
[
alloc_index
].
Trustee
.
MultipleTrusteeOperation
;
for
(
i
=
0
;
i
<
count
;
++
i
,
++
ptrA
,
++
ptrW
)
pEntriesW
[
alloc_index
].
Trustee
.
TrusteeForm
=
pEntries
[
alloc_index
].
Trustee
.
TrusteeForm
;
{
pEntriesW
[
alloc_index
].
Trustee
.
TrusteeType
=
pEntries
[
alloc_index
].
Trustee
.
TrusteeType
;
ptrW
->
grfAccessPermissions
=
ptrA
->
grfAccessPermissions
;
ptrW
->
grfAccessMode
=
ptrA
->
grfAccessMode
;
err
=
trustee_name_A_to_W
(
pEntries
[
alloc_index
].
Trustee
.
TrusteeForm
,
ptrW
->
grfInheritance
=
ptrA
->
grfInheritance
;
pEntries
[
alloc_index
].
Trustee
.
ptstrName
,
ptrW
->
Trustee
.
pMultipleTrustee
=
NULL
;
/* currently not supported */
&
pEntriesW
[
alloc_index
].
Trustee
.
ptstrName
);
ptrW
->
Trustee
.
MultipleTrusteeOperation
=
ptrA
->
Trustee
.
MultipleTrusteeOperation
;
if
(
err
!=
ERROR_SUCCESS
)
ptrW
->
Trustee
.
TrusteeForm
=
ptrA
->
Trustee
.
TrusteeForm
;
{
ptrW
->
Trustee
.
TrusteeType
=
ptrA
->
Trustee
.
TrusteeType
;
if
(
err
==
ERROR_INVALID_PARAMETER
)
wstr
=
NULL
;
WARN
(
"bad trustee form %d for trustee %d
\n
"
,
if
(
ptrA
->
Trustee
.
ptstrName
)
pEntries
[
alloc_index
].
Trustee
.
TrusteeForm
,
alloc_index
);
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
ptrA
->
Trustee
.
ptstrName
,
-
1
,
NULL
,
0
);
goto
cleanup
;
wstr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
ptrA
->
Trustee
.
ptstrName
,
-
1
,
wstr
,
len
);
}
}
ptrW
->
Trustee
.
ptstrName
=
wstr
;
}
}
err
=
SetEntriesInAclW
(
count
,
pEntriesW
,
OldAcl
,
NewAcl
);
err
=
SetEntriesInAclW
(
count
,
pEntriesW
,
OldAcl
,
NewAcl
);
ptrW
=
pEntriesW
;
cleanup:
for
(
i
=
0
;
i
<
count
;
++
i
,
++
ptrW
)
/* Free any previously allocated trustee name buffers, taking into account
{
* a possible out-of-memory condition while building the EXPLICIT_ACCESSW
HeapFree
(
GetProcessHeap
(),
0
,
ptrW
->
Trustee
.
ptstrName
);
* list. */
}
for
(
free_index
=
0
;
free_index
<
alloc_index
;
++
free_index
)
free_trustee_name
(
pEntriesW
[
free_index
].
Trustee
.
TrusteeForm
,
pEntriesW
[
free_index
].
Trustee
.
ptstrName
);
HeapFree
(
GetProcessHeap
(),
0
,
pEntriesW
);
HeapFree
(
GetProcessHeap
(),
0
,
pEntriesW
);
}
else
{
err
=
ERROR_NOT_ENOUGH_MEMORY
;
}
return
err
;
return
err
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment