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
3c51b2c6
Commit
3c51b2c6
authored
Sep 27, 2007
by
Mikolaj Zalewski
Committed by
Alexandre Julliard
Sep 28, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32/ntdll: MakeRelativeSD should preserve NULL pointers (with testcase).
parent
cf84cbac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
11 deletions
+71
-11
security.c
dlls/advapi32/tests/security.c
+46
-0
sec.c
dlls/ntdll/sec.c
+25
-11
No files found.
dlls/advapi32/tests/security.c
View file @
3c51b2c6
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include "wine/test.h"
#include "wine/test.h"
#define expect_eq(expr, value, type, format) { type ret = expr; ok((value) == ret, #expr " expected " format " got " format "\n", (value), (ret)); }
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithSidA
)(
PTRUSTEEA
pTrustee
,
PSID
pSid
);
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithSidA
)(
PTRUSTEEA
pTrustee
,
PSID
pSid
);
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithNameA
)(
PTRUSTEEA
pTrustee
,
LPSTR
pName
);
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithNameA
)(
PTRUSTEEA
pTrustee
,
LPSTR
pName
);
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithObjectsAndNameA
)(
PTRUSTEEA
pTrustee
,
typedef
VOID
(
WINAPI
*
fnBuildTrusteeWithObjectsAndNameA
)(
PTRUSTEEA
pTrustee
,
...
@@ -49,6 +51,7 @@ typedef VOID (WINAPI *fnBuildTrusteeWithObjectsAndSidA)( PTRUSTEEA pTrustee,
...
@@ -49,6 +51,7 @@ typedef VOID (WINAPI *fnBuildTrusteeWithObjectsAndSidA)( PTRUSTEEA pTrustee,
GUID
*
pInheritedObjectGuid
,
GUID
*
pInheritedObjectGuid
,
PSID
pSid
);
PSID
pSid
);
typedef
LPSTR
(
WINAPI
*
fnGetTrusteeNameA
)(
PTRUSTEEA
pTrustee
);
typedef
LPSTR
(
WINAPI
*
fnGetTrusteeNameA
)(
PTRUSTEEA
pTrustee
);
typedef
BOOL
(
WINAPI
*
fnMakeSelfRelativeSD
)(
PSECURITY_DESCRIPTOR
,
PSECURITY_DESCRIPTOR
,
LPDWORD
);
typedef
BOOL
(
WINAPI
*
fnConvertSidToStringSidA
)(
PSID
pSid
,
LPSTR
*
str
);
typedef
BOOL
(
WINAPI
*
fnConvertSidToStringSidA
)(
PSID
pSid
,
LPSTR
*
str
);
typedef
BOOL
(
WINAPI
*
fnConvertStringSidToSidA
)(
LPCSTR
str
,
PSID
pSid
);
typedef
BOOL
(
WINAPI
*
fnConvertStringSidToSidA
)(
LPCSTR
str
,
PSID
pSid
);
static
BOOL
(
WINAPI
*
pConvertStringSecurityDescriptorToSecurityDescriptorA
)(
LPCSTR
,
DWORD
,
static
BOOL
(
WINAPI
*
pConvertStringSecurityDescriptorToSecurityDescriptorA
)(
LPCSTR
,
DWORD
,
...
@@ -81,6 +84,7 @@ fnBuildTrusteeWithNameA pBuildTrusteeWithNameA;
...
@@ -81,6 +84,7 @@ fnBuildTrusteeWithNameA pBuildTrusteeWithNameA;
fnBuildTrusteeWithObjectsAndNameA
pBuildTrusteeWithObjectsAndNameA
;
fnBuildTrusteeWithObjectsAndNameA
pBuildTrusteeWithObjectsAndNameA
;
fnBuildTrusteeWithObjectsAndSidA
pBuildTrusteeWithObjectsAndSidA
;
fnBuildTrusteeWithObjectsAndSidA
pBuildTrusteeWithObjectsAndSidA
;
fnGetTrusteeNameA
pGetTrusteeNameA
;
fnGetTrusteeNameA
pGetTrusteeNameA
;
fnMakeSelfRelativeSD
pMakeSelfRelativeSD
;
fnConvertSidToStringSidA
pConvertSidToStringSidA
;
fnConvertSidToStringSidA
pConvertSidToStringSidA
;
fnConvertStringSidToSidA
pConvertStringSidToSidA
;
fnConvertStringSidToSidA
pConvertStringSidToSidA
;
fnGetFileSecurityA
pGetFileSecurityA
;
fnGetFileSecurityA
pGetFileSecurityA
;
...
@@ -110,6 +114,7 @@ static void init(void)
...
@@ -110,6 +114,7 @@ static void init(void)
(
void
*
)
GetProcAddress
(
hmod
,
"ConvertStringSecurityDescriptorToSecurityDescriptorA"
);
(
void
*
)
GetProcAddress
(
hmod
,
"ConvertStringSecurityDescriptorToSecurityDescriptorA"
);
pConvertSecurityDescriptorToStringSecurityDescriptorA
=
pConvertSecurityDescriptorToStringSecurityDescriptorA
=
(
void
*
)
GetProcAddress
(
hmod
,
"ConvertSecurityDescriptorToStringSecurityDescriptorA"
);
(
void
*
)
GetProcAddress
(
hmod
,
"ConvertSecurityDescriptorToStringSecurityDescriptorA"
);
pMakeSelfRelativeSD
=
(
void
*
)
GetProcAddress
(
hmod
,
"MakeSelfRelativeSD"
);
pGetNamedSecurityInfoA
=
(
void
*
)
GetProcAddress
(
hmod
,
"GetNamedSecurityInfoA"
);
pGetNamedSecurityInfoA
=
(
void
*
)
GetProcAddress
(
hmod
,
"GetNamedSecurityInfoA"
);
pSetEntriesInAclW
=
(
void
*
)
GetProcAddress
(
hmod
,
"SetEntriesInAclW"
);
pSetEntriesInAclW
=
(
void
*
)
GetProcAddress
(
hmod
,
"SetEntriesInAclW"
);
...
@@ -1443,6 +1448,46 @@ static void test_LookupAccountName(void)
...
@@ -1443,6 +1448,46 @@ static void test_LookupAccountName(void)
HeapFree
(
GetProcessHeap
(),
0
,
domain
);
HeapFree
(
GetProcessHeap
(),
0
,
domain
);
}
}
static
void
test_security_descriptor
(
void
)
{
SECURITY_DESCRIPTOR
sd
;
char
buf
[
8192
];
DWORD
size
;
BOOL
isDefault
,
isPresent
;
PACL
pacl
;
PSID
psid
;
InitializeSecurityDescriptor
(
&
sd
,
SECURITY_DESCRIPTOR_REVISION
);
ok
(
GetSecurityDescriptorOwner
(
&
sd
,
&
psid
,
&
isDefault
),
"GetSecurityDescriptorOwner failed
\n
"
);
expect_eq
(
psid
,
NULL
,
PSID
,
"%p"
);
todo_wine
expect_eq
(
isDefault
,
FALSE
,
BOOL
,
"%d"
);
sd
.
Control
|=
SE_DACL_PRESENT
|
SE_SACL_PRESENT
;
SetLastError
(
0xdeadbeef
);
size
=
5
;
expect_eq
(
MakeSelfRelativeSD
(
&
sd
,
buf
,
&
size
),
FALSE
,
BOOL
,
"%d"
);
expect_eq
(
GetLastError
(),
ERROR_INSUFFICIENT_BUFFER
,
DWORD
,
"%u"
);
ok
(
size
>
5
,
"Size not increased
\n
"
);
if
(
size
<=
8192
)
{
expect_eq
(
MakeSelfRelativeSD
(
&
sd
,
buf
,
&
size
),
TRUE
,
BOOL
,
"%d"
);
ok
(
GetSecurityDescriptorOwner
(
&
sd
,
&
psid
,
&
isDefault
),
"GetSecurityDescriptorOwner failed
\n
"
);
expect_eq
(
psid
,
NULL
,
PSID
,
"%p"
);
todo_wine
expect_eq
(
isDefault
,
FALSE
,
BOOL
,
"%d"
);
ok
(
GetSecurityDescriptorGroup
(
&
sd
,
&
psid
,
&
isDefault
),
"GetSecurityDescriptorOwner failed
\n
"
);
expect_eq
(
psid
,
NULL
,
PSID
,
"%p"
);
todo_wine
expect_eq
(
isDefault
,
FALSE
,
BOOL
,
"%d"
);
ok
(
GetSecurityDescriptorDacl
(
&
sd
,
&
isPresent
,
&
pacl
,
&
isDefault
),
"GetSecurityDescriptorOwner failed
\n
"
);
expect_eq
(
isPresent
,
TRUE
,
BOOL
,
"%d"
);
expect_eq
(
psid
,
NULL
,
PSID
,
"%p"
);
expect_eq
(
isDefault
,
FALSE
,
BOOL
,
"%d"
);
ok
(
GetSecurityDescriptorSacl
(
&
sd
,
&
isPresent
,
&
pacl
,
&
isDefault
),
"GetSecurityDescriptorOwner failed
\n
"
);
expect_eq
(
isPresent
,
TRUE
,
BOOL
,
"%d"
);
expect_eq
(
psid
,
NULL
,
PSID
,
"%p"
);
expect_eq
(
isDefault
,
FALSE
,
BOOL
,
"%d"
);
}
}
#define TEST_GRANTED_ACCESS(a,b) test_granted_access(a,b,__LINE__)
#define TEST_GRANTED_ACCESS(a,b) test_granted_access(a,b,__LINE__)
static
void
test_granted_access
(
HANDLE
handle
,
ACCESS_MASK
access
,
int
line
)
static
void
test_granted_access
(
HANDLE
handle
,
ACCESS_MASK
access
,
int
line
)
{
{
...
@@ -2017,6 +2062,7 @@ START_TEST(security)
...
@@ -2017,6 +2062,7 @@ START_TEST(security)
test_token_attr
();
test_token_attr
();
test_LookupAccountSid
();
test_LookupAccountSid
();
test_LookupAccountName
();
test_LookupAccountName
();
test_security_descriptor
();
test_process_security
();
test_process_security
();
test_impersonation_level
();
test_impersonation_level
();
test_SetEntriesInAcl
();
test_SetEntriesInAcl
();
...
...
dlls/ntdll/sec.c
View file @
3c51b2c6
...
@@ -848,30 +848,44 @@ NTSTATUS WINAPI RtlMakeSelfRelativeSD(
...
@@ -848,30 +848,44 @@ NTSTATUS WINAPI RtlMakeSelfRelativeSD(
pRel
->
Control
=
pAbs
->
Control
|
SE_SELF_RELATIVE
;
pRel
->
Control
=
pAbs
->
Control
|
SE_SELF_RELATIVE
;
offsetRel
=
sizeof
(
SECURITY_DESCRIPTOR
);
offsetRel
=
sizeof
(
SECURITY_DESCRIPTOR
);
pRel
->
Owner
=
(
PSID
)
offsetRel
;
if
(
pAbs
->
Owner
)
length
=
RtlLengthSid
(
pAbs
->
Owner
);
{
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Owner
,
length
);
pRel
->
Owner
=
(
PSID
)
offsetRel
;
length
=
RtlLengthSid
(
pAbs
->
Owner
);
offsetRel
+=
length
;
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Owner
,
length
);
pRel
->
Group
=
(
PSID
)
offsetRel
;
offsetRel
+=
length
;
length
=
RtlLengthSid
(
pAbs
->
Group
);
}
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Group
,
length
);
else
{
pRel
->
Owner
=
NULL
;
}
if
(
p
Rel
->
Control
&
SE_SACL_PRESENT
)
if
(
p
Abs
->
Group
)
{
{
pRel
->
Group
=
(
PSID
)
offsetRel
;
length
=
RtlLengthSid
(
pAbs
->
Group
);
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Group
,
length
);
offsetRel
+=
length
;
offsetRel
+=
length
;
}
else
{
pRel
->
Group
=
NULL
;
}
if
(
pAbs
->
Sacl
)
{
pRel
->
Sacl
=
(
PACL
)
offsetRel
;
pRel
->
Sacl
=
(
PACL
)
offsetRel
;
length
=
pAbs
->
Sacl
->
AclSize
;
length
=
pAbs
->
Sacl
->
AclSize
;
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Sacl
,
length
);
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Sacl
,
length
);
offsetRel
+=
length
;
}
}
else
else
{
{
pRel
->
Sacl
=
NULL
;
pRel
->
Sacl
=
NULL
;
}
}
if
(
p
Rel
->
Control
&
SE_DACL_PRESENT
)
if
(
p
Abs
->
Dacl
)
{
{
offsetRel
+=
length
;
pRel
->
Dacl
=
(
PACL
)
offsetRel
;
pRel
->
Dacl
=
(
PACL
)
offsetRel
;
length
=
pAbs
->
Dacl
->
AclSize
;
length
=
pAbs
->
Dacl
->
AclSize
;
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Dacl
,
length
);
memcpy
((
LPBYTE
)
pRel
+
offsetRel
,
pAbs
->
Dacl
,
length
);
...
...
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