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
c0b7345e
Commit
c0b7345e
authored
Jun 01, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jun 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Fix last error value of GetUserNameA/W and output buffer handling in GetUserNameA.
parent
c8ea11c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
21 deletions
+7
-21
advapi.c
dlls/advapi32/advapi.c
+7
-11
security.c
dlls/advapi32/tests/security.c
+0
-10
No files found.
dlls/advapi32/advapi.c
View file @
c0b7345e
...
@@ -55,24 +55,20 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
...
@@ -55,24 +55,20 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
{
{
WCHAR
*
buffer
;
WCHAR
*
buffer
;
BOOL
ret
;
BOOL
ret
;
DWORD
sizeW
=
*
lpSize
*
2
;
DWORD
sizeW
=
*
lpSize
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeW
*
sizeof
(
WCHAR
)
)))
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeW
*
sizeof
(
WCHAR
)
)))
{
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
return
FALSE
;
}
}
ret
=
GetUserNameW
(
buffer
,
&
sizeW
);
ret
=
GetUserNameW
(
buffer
,
&
sizeW
);
if
(
ret
)
if
(
ret
)
{
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpszName
,
*
lpSize
,
NULL
,
NULL
);
if
(
!
(
*
lpSize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpszName
,
*
lpSize
,
NULL
,
NULL
)))
else
{
*
lpSize
=
sizeW
;
*
lpSize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
}
else
*
lpSize
=
sizeW
*
2
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
ret
;
return
ret
;
}
}
...
@@ -91,7 +87,7 @@ GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
...
@@ -91,7 +87,7 @@ GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
if
(
len
>
*
lpSize
)
if
(
len
>
*
lpSize
)
{
{
SetLastError
(
ERROR_MORE_DATA
);
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
*
lpSize
=
len
;
*
lpSize
=
len
;
return
FALSE
;
return
FALSE
;
}
}
...
...
dlls/advapi32/tests/security.c
View file @
c0b7345e
...
@@ -3741,7 +3741,6 @@ static void test_GetUserNameA(void)
...
@@ -3741,7 +3741,6 @@ static void test_GetUserNameA(void)
ret
=
GetUserNameA
(
NULL
,
&
required_len
);
ret
=
GetUserNameA
(
NULL
,
&
required_len
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -3749,7 +3748,6 @@ static void test_GetUserNameA(void)
...
@@ -3749,7 +3748,6 @@ static void test_GetUserNameA(void)
ret
=
GetUserNameA
(
NULL
,
&
required_len
);
ret
=
GetUserNameA
(
NULL
,
&
required_len
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
required_len
!=
0
&&
required_len
!=
1
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
&&
required_len
!=
1
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
/* Tests crashes on Windows. */
/* Tests crashes on Windows. */
...
@@ -3774,7 +3772,6 @@ static void test_GetUserNameA(void)
...
@@ -3774,7 +3772,6 @@ static void test_GetUserNameA(void)
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was altered
\n
"
);
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was altered
\n
"
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -3783,7 +3780,6 @@ static void test_GetUserNameA(void)
...
@@ -3783,7 +3780,6 @@ static void test_GetUserNameA(void)
ret
=
GetUserNameA
(
buffer
,
&
buffer_len
);
ret
=
GetUserNameA
(
buffer
,
&
buffer_len
);
ok
(
ret
==
TRUE
,
"GetUserNameA returned %d, last error %u
\n
"
,
ret
,
GetLastError
());
ok
(
ret
==
TRUE
,
"GetUserNameA returned %d, last error %u
\n
"
,
ret
,
GetLastError
());
ok
(
memcmp
(
buffer
,
filler
,
sizeof
(
filler
))
!=
0
,
"Output buffer was untouched
\n
"
);
ok
(
memcmp
(
buffer
,
filler
,
sizeof
(
filler
))
!=
0
,
"Output buffer was untouched
\n
"
);
todo_wine
ok
(
buffer_len
==
required_len
||
ok
(
buffer_len
==
required_len
||
broken
(
buffer_len
==
required_len
/
sizeof
(
WCHAR
)),
/* XP+ */
broken
(
buffer_len
==
required_len
/
sizeof
(
WCHAR
)),
/* XP+ */
"Outputted buffer length was %u
\n
"
,
buffer_len
);
"Outputted buffer length was %u
\n
"
,
buffer_len
);
...
@@ -3795,11 +3791,9 @@ static void test_GetUserNameA(void)
...
@@ -3795,11 +3791,9 @@ static void test_GetUserNameA(void)
buffer_len
--
;
buffer_len
--
;
ret
=
GetUserNameA
(
buffer
,
&
buffer_len
);
ret
=
GetUserNameA
(
buffer
,
&
buffer_len
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameA returned %d
\n
"
,
ret
);
todo_wine
{
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was untouched
\n
"
);
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was untouched
\n
"
);
ok
(
buffer_len
==
required_len
,
"Outputted buffer length was %u
\n
"
,
buffer_len
);
ok
(
buffer_len
==
required_len
,
"Outputted buffer length was %u
\n
"
,
buffer_len
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
}
}
}
static
void
test_GetUserNameW
(
void
)
static
void
test_GetUserNameW
(
void
)
...
@@ -3820,7 +3814,6 @@ static void test_GetUserNameW(void)
...
@@ -3820,7 +3814,6 @@ static void test_GetUserNameW(void)
ret
=
GetUserNameW
(
NULL
,
&
required_len
);
ret
=
GetUserNameW
(
NULL
,
&
required_len
);
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -3828,7 +3821,6 @@ static void test_GetUserNameW(void)
...
@@ -3828,7 +3821,6 @@ static void test_GetUserNameW(void)
ret
=
GetUserNameW
(
NULL
,
&
required_len
);
ret
=
GetUserNameW
(
NULL
,
&
required_len
);
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
required_len
!=
0
&&
required_len
!=
1
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
&&
required_len
!=
1
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
/* Tests crash on Windows. */
/* Tests crash on Windows. */
...
@@ -3851,7 +3843,6 @@ static void test_GetUserNameW(void)
...
@@ -3851,7 +3843,6 @@ static void test_GetUserNameW(void)
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
ret
==
FALSE
,
"GetUserNameW returned %d
\n
"
,
ret
);
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was altered
\n
"
);
ok
(
!
memcmp
(
buffer
,
filler
,
sizeof
(
filler
)),
"Output buffer was altered
\n
"
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
ok
(
required_len
!=
0
,
"Outputted buffer length was %u
\n
"
,
required_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -3872,7 +3863,6 @@ static void test_GetUserNameW(void)
...
@@ -3872,7 +3863,6 @@ static void test_GetUserNameW(void)
broken
(
memcmp
(
buffer
,
filler
,
sizeof
(
filler
))
!=
0
),
/* XP+ */
broken
(
memcmp
(
buffer
,
filler
,
sizeof
(
filler
))
!=
0
),
/* XP+ */
"Output buffer was altered
\n
"
);
"Output buffer was altered
\n
"
);
ok
(
buffer_len
==
required_len
,
"Outputted buffer length was %u
\n
"
,
buffer_len
);
ok
(
buffer_len
==
required_len
,
"Outputted buffer length was %u
\n
"
,
buffer_len
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Last error was %u
\n
"
,
GetLastError
());
}
}
...
...
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