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
a630510b
Commit
a630510b
authored
Nov 20, 2001
by
James Juran
Committed by
Alexandre Julliard
Nov 20, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GetUserName should include the terminating null character when
returning the size of the buffer returned. Correctly handle the ERROR_MORE_DATA case.
parent
55a14edd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
advapi.c
dlls/advapi32/advapi.c
+20
-5
No files found.
dlls/advapi32/advapi.c
View file @
a630510b
...
...
@@ -4,6 +4,7 @@
* Copyright 1995 Sven Verdoolaege
*/
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
...
...
@@ -16,9 +17,13 @@
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL
(
advapi
);
/******************************************************************************
* GetUserNameA [ADVAPI32.@]
*
* NOTE: lpSize returns the total length of the username, including the
* terminating null character.
*/
BOOL
WINAPI
GetUserNameA
(
LPSTR
lpszName
,
LPDWORD
lpSize
)
...
...
@@ -27,14 +32,24 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
char
*
name
;
struct
passwd
*
pwd
=
getpwuid
(
getuid
()
);
if
(
!
pwd
)
return
0
;
if
(
!
pwd
)
{
ERR
(
"Username lookup failed: %s
\n
"
,
strerror
(
errno
));
return
0
;
}
name
=
pwd
->
pw_name
;
len
=
name
?
strlen
(
name
)
:
0
;
if
(
!
len
||
!
lpSize
||
len
>
*
lpSize
)
{
if
(
lpszName
)
*
lpszName
=
0
;
/* We need to include the null character when determining the size of the buffer. */
len
=
strlen
(
name
)
+
1
;
if
(
len
>
*
lpSize
)
{
SetLastError
(
ERROR_MORE_DATA
);
*
lpSize
=
len
;
return
0
;
}
*
lpSize
=
len
;
*
lpSize
=
len
;
strcpy
(
lpszName
,
name
);
return
1
;
}
...
...
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