Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f0085e63
Commit
f0085e63
authored
Aug 25, 2006
by
Robert Reif
Committed by
Alexandre Julliard
Aug 26, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Fix LookupAccountSid and tests to pass on windows and wine.
parent
ee32bd99
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
55 deletions
+147
-55
security.c
dlls/advapi32/security.c
+9
-3
security.c
dlls/advapi32/tests/security.c
+138
-52
No files found.
dlls/advapi32/security.c
View file @
f0085e63
...
...
@@ -1854,14 +1854,14 @@ LookupAccountSidA(
WideCharToMultiByte
(
CP_ACP
,
0
,
accountW
,
-
1
,
account
,
len
,
NULL
,
NULL
);
*
accountSize
=
len
;
}
else
*
accountSize
=
accountSizeW
;
*
accountSize
=
accountSizeW
+
1
;
if
(
domainW
&&
*
domainSize
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
domainW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
WideCharToMultiByte
(
CP_ACP
,
0
,
domainW
,
-
1
,
domain
,
len
,
NULL
,
NULL
);
*
domainSize
=
len
;
}
else
*
domainSize
=
domainSizeW
;
*
domainSize
=
domainSizeW
+
1
;
}
HeapFree
(
GetProcessHeap
(),
0
,
systemW
);
...
...
@@ -2007,10 +2007,16 @@ LookupAccountSidW(
}
if
(((
*
accountSize
!=
0
)
&&
(
*
accountSize
<
strlenW
(
ac
)))
||
((
*
domainSize
!=
0
)
&&
(
*
domainSize
<
strlenW
(
dm
))))
{
SetLastError
(
ERROR_
NOT_ENOUGH_MEMORY
);
SetLastError
(
ERROR_
INSUFFICIENT_BUFFER
);
status
=
FALSE
;
}
if
(
*
domainSize
)
*
domainSize
=
strlenW
(
dm
);
else
*
domainSize
=
strlenW
(
dm
)
+
1
;
if
(
*
accountSize
)
*
accountSize
=
strlenW
(
ac
);
else
*
accountSize
=
strlenW
(
ac
)
+
1
;
*
name_use
=
use
;
HeapFree
(
GetProcessHeap
(),
0
,
computer_name
);
...
...
dlls/advapi32/tests/security.c
View file @
f0085e63
...
...
@@ -878,15 +878,18 @@ static void test_sid_str(PSID * sid)
static
void
test_LookupAccountSid
(
void
)
{
SID_IDENTIFIER_AUTHORITY
SIDAuthNT
=
{
SECURITY_NT_AUTHORITY
};
char
account
[
MAX_PATH
],
domain
[
MAX_PATH
];
DWORD
acc_size
,
dom_size
;
DWORD
real_acc_size
,
real_dom_size
;
CHAR
accountA
[
MAX_PATH
],
domainA
[
MAX_PATH
];
DWORD
acc_sizeA
,
dom_sizeA
;
DWORD
real_acc_sizeA
,
real_dom_sizeA
;
WCHAR
accountW
[
MAX_PATH
],
domainW
[
MAX_PATH
];
DWORD
acc_sizeW
,
dom_sizeW
;
DWORD
real_acc_sizeW
,
real_dom_sizeW
;
PSID
pUsersSid
=
NULL
;
SID_NAME_USE
use
;
BOOL
ret
;
DWORD
size
;
MAX_SID
max_sid
;
char
*
str_sid
;
CHAR
*
str_sidA
;
int
i
;
/* native windows crashes if account size, domain size, or name use is NULL */
...
...
@@ -900,68 +903,151 @@ static void test_LookupAccountSid(void)
if
(
!
ret
&&
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
))
return
;
real_acc_size
=
MAX_PATH
;
real_dom_size
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
account
,
&
real_acc_size
,
domain
,
&
real_dom_size
,
&
use
);
ok
(
ret
,
"LookupAccountSid() Expected TRUE, got FALSE
\n
"
);
real_acc_sizeA
=
MAX_PATH
;
real_dom_sizeA
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
real_acc_sizeA
,
domainA
,
&
real_dom_sizeA
,
&
use
);
ok
(
ret
,
"LookupAccountSidA() Expected TRUE, got FALSE
\n
"
);
/* try NULL account */
acc_sizeA
=
MAX_PATH
;
dom_sizeA
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
NULL
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
ok
(
ret
,
"LookupAccountSidA() Expected TRUE, got FALSE
\n
"
);
/* try NULL domain */
acc_sizeA
=
MAX_PATH
;
dom_sizeA
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
NULL
,
&
dom_sizeA
,
&
use
);
ok
(
ret
,
"LookupAccountSidA() Expected TRUE, got FALSE
\n
"
);
/* try a small account buffer */
acc_sizeA
=
1
;
dom_sizeA
=
MAX_PATH
;
accountA
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
ok
(
!
ret
,
"LookupAccountSidA() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"LookupAccountSidA() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
/* try a 0 sized account buffer */
acc_sizeA
=
0
;
dom_sizeA
=
MAX_PATH
;
accountA
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
acc_sizeA
==
real_acc_sizeA
+
1
,
"LookupAccountSidA() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_sizeA
+
1
,
acc_sizeA
);
/* try a 0 sized account buffer */
acc_sizeA
=
0
;
dom_sizeA
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
NULL
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
acc_sizeA
==
real_acc_sizeA
+
1
,
"LookupAccountSid() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_sizeA
+
1
,
acc_sizeA
);
/* try a small domain buffer */
dom_sizeA
=
1
;
acc_sizeA
=
MAX_PATH
;
accountA
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
ok
(
!
ret
,
"LookupAccountSidA() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"LookupAccountSidA() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
/* try a 0 sized domain buffer */
dom_sizeA
=
0
;
acc_sizeA
=
MAX_PATH
;
accountA
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
dom_sizeA
==
real_dom_sizeA
+
1
,
"LookupAccountSidA() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_sizeA
+
1
,
dom_sizeA
);
/* try a 0 sized domain buffer */
dom_sizeA
=
0
;
acc_sizeA
=
MAX_PATH
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
accountA
,
&
acc_sizeA
,
NULL
,
&
dom_sizeA
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
dom_sizeA
==
real_dom_sizeA
+
1
,
"LookupAccountSidA() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_sizeA
+
1
,
dom_sizeA
);
real_acc_sizeW
=
MAX_PATH
;
real_dom_sizeW
=
MAX_PATH
;
ret
=
LookupAccountSidW
(
NULL
,
pUsersSid
,
accountW
,
&
real_acc_sizeW
,
domainW
,
&
real_dom_sizeW
,
&
use
);
ok
(
ret
,
"LookupAccountSidW() Expected TRUE, got FALSE
\n
"
);
/* try NULL account */
acc_size
=
MAX_PATH
;
dom_size
=
MAX_PATH
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
NULL
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
ok
(
ret
,
"LookupAccountSid() Expected TRUE, got FALSE
\n
"
);
acc_size
W
=
MAX_PATH
;
dom_size
W
=
MAX_PATH
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
NULL
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
ok
(
ret
,
"LookupAccountSid
W
() Expected TRUE, got FALSE
\n
"
);
/* try NULL domain */
acc_size
=
MAX_PATH
;
dom_size
=
MAX_PATH
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
NULL
,
&
dom_size
,
&
use
);
ok
(
ret
,
"LookupAccountSid() Expected TRUE, got FALSE
\n
"
);
acc_size
W
=
MAX_PATH
;
dom_size
W
=
MAX_PATH
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
NULL
,
&
dom_sizeW
,
&
use
);
ok
(
ret
,
"LookupAccountSid
W
() Expected TRUE, got FALSE
\n
"
);
/* try a small account buffer */
acc_size
=
1
;
dom_size
=
MAX_PATH
;
account
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
ok
(
!
ret
,
"LookupAccountSid() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
"LookupAccountSid() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
acc_sizeW
=
1
;
dom_sizeW
=
MAX_PATH
;
accountW
[
0
]
=
0
;
ret
=
LookupAccountSidW
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
ok
(
!
ret
,
"LookupAccountSidW() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"LookupAccountSidW() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
/* try a 0 sized account buffer */
acc_size
=
0
;
dom_size
=
MAX_PATH
;
account
[
0
]
=
0
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
acc_size
W
=
0
;
dom_size
W
=
MAX_PATH
;
account
W
[
0
]
=
0
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
acc_size
==
real_acc_size
,
"LookupAccountSid() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_size
,
acc_size
);
ok
(
acc_sizeW
==
real_acc_sizeW
+
1
,
"LookupAccountSidW() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_sizeW
+
1
,
acc_sizeW
);
/* try a 0 sized account buffer */
acc_size
=
0
;
dom_size
=
MAX_PATH
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
NULL
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
acc_size
W
=
0
;
dom_size
W
=
MAX_PATH
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
NULL
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
acc_size
==
real_acc_size
,
"LookupAccountSid() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_size
,
acc_size
);
ok
(
acc_sizeW
==
real_acc_sizeW
+
1
,
"LookupAccountSidW() Expected acc_size = %lu, got %lu
\n
"
,
real_acc_sizeW
+
1
,
acc_sizeW
);
/* try a small domain buffer */
dom_size
=
1
;
acc_size
=
MAX_PATH
;
account
[
0
]
=
0
;
ret
=
LookupAccountSidA
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
ok
(
!
ret
,
"LookupAccountSid() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
"LookupAccountSid() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
dom_sizeW
=
1
;
acc_sizeW
=
MAX_PATH
;
accountW
[
0
]
=
0
;
ret
=
LookupAccountSidW
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
ok
(
!
ret
,
"LookupAccountSidW() Expected FALSE got TRUE
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"LookupAccountSidW() Expected ERROR_NOT_ENOUGH_MEMORY, got %lu
\n
"
,
GetLastError
());
/* try a 0 sized domain buffer */
dom_size
=
0
;
acc_size
=
MAX_PATH
;
account
[
0
]
=
0
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
);
dom_size
W
=
0
;
acc_size
W
=
MAX_PATH
;
account
W
[
0
]
=
0
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
domainW
,
&
dom_sizeW
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
dom_size
==
real_dom_size
,
"LookupAccountSid() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_size
,
dom_size
);
ok
(
dom_sizeW
==
real_dom_sizeW
+
1
,
"LookupAccountSidW() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_sizeW
+
1
,
dom_sizeW
);
/* try a 0 sized domain buffer */
dom_size
=
0
;
acc_size
=
MAX_PATH
;
ret
=
LookupAccountSid
A
(
NULL
,
pUsersSid
,
account
,
&
acc_size
,
NULL
,
&
dom_size
,
&
use
);
dom_size
W
=
0
;
acc_size
W
=
MAX_PATH
;
ret
=
LookupAccountSid
W
(
NULL
,
pUsersSid
,
accountW
,
&
acc_sizeW
,
NULL
,
&
dom_sizeW
,
&
use
);
/* this can fail or succeed depending on OS version but the size will always be returned */
ok
(
acc_size
==
real_acc_size
,
"LookupAccountSid() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_size
,
dom_size
);
ok
(
dom_sizeW
==
real_dom_sizeW
+
1
,
"LookupAccountSidW() Expected dom_size = %lu, got %lu
\n
"
,
real_dom_sizeW
+
1
,
dom_sizeW
);
pCreateWellKnownSid
=
(
fnCreateWellKnownSid
)
GetProcAddress
(
hmod
,
"CreateWellKnownSid"
);
...
...
@@ -973,13 +1059,13 @@ static void test_LookupAccountSid(void)
size
=
SECURITY_MAX_SID_SIZE
;
if
(
pCreateWellKnownSid
(
i
,
NULL
,
&
max_sid
.
sid
,
&
size
))
{
if
(
pConvertSidToStringSidA
(
&
max_sid
.
sid
,
&
str_sid
))
if
(
pConvertSidToStringSidA
(
&
max_sid
.
sid
,
&
str_sid
A
))
{
acc_size
=
MAX_PATH
;
dom_size
=
MAX_PATH
;
if
(
LookupAccountSid
(
NULL
,
&
max_sid
.
sid
,
account
,
&
acc_size
,
domain
,
&
dom_size
,
&
use
))
trace
(
" %d: %s %s
\\
%s %d
\n
"
,
i
,
str_sid
,
domain
,
account
,
use
);
LocalFree
(
str_sid
);
acc_size
A
=
MAX_PATH
;
dom_size
A
=
MAX_PATH
;
if
(
LookupAccountSid
A
(
NULL
,
&
max_sid
.
sid
,
accountA
,
&
acc_sizeA
,
domainA
,
&
dom_sizeA
,
&
use
))
trace
(
" %d: %s %s
\\
%s %d
\n
"
,
i
,
str_sid
A
,
domainA
,
accountA
,
use
);
LocalFree
(
str_sid
A
);
}
}
else
...
...
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