mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-11-09 08:37:58 +08:00
2010-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com>
* libcsupport/src/getlogin.c: Modify to use strncpy() on all paths.
This commit is contained in:
1 parent
8cb97f594f
commit
fb90d67b2f
2 files changed
+12
-5
No files matched your search
@@ -1,3 +1,7 @@
|
||||
2010-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com>
|
||||
|
||||
* libcsupport/src/getlogin.c: Modify to use strncpy() on all paths.
|
||||
|
||||
2010-08-28 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
PR 1694/shell
|
||||
|
||||
@@ -41,6 +41,7 @@ int getlogin_r(
|
||||
)
|
||||
{
|
||||
struct passwd *pw;
|
||||
char *pname;
|
||||
|
||||
if ( !name )
|
||||
return EFAULT;
|
||||
@@ -48,11 +49,13 @@ int getlogin_r(
|
||||
if ( namesize < LOGIN_NAME_MAX )
|
||||
return ERANGE;
|
||||
|
||||
/* Set the pointer to a default name */
|
||||
pname = "";
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
if ( !pw ) {
|
||||
strcpy( name, "" );
|
||||
} else {
|
||||
strncpy( name, pw->pw_name, LOGIN_NAME_MAX );
|
||||
}
|
||||
if ( pw )
|
||||
pname = pw->pw_name;
|
||||
|
||||
strncpy( name, pname, LOGIN_NAME_MAX );
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user