diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-08-29 19:48:52 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-08-29 19:48:52 +0000 |
commit | fb90d67b2fe8fd4017e9f55911ceb9dfa06f36e4 (patch) | |
tree | 38c0e269e79460c9018c6b8265ce24ee58e4fd76 /cpukit | |
parent | 2010-08-28 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-fb90d67b2fe8fd4017e9f55911ceb9dfa06f36e4.tar.bz2 |
2010-08-29 Joel Sherrill <joel.sherrilL@OARcorp.com>
* libcsupport/src/getlogin.c: Modify to use strncpy() on all paths.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 4 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getlogin.c | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 6cfceebccc..40df254d4f 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -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 diff --git a/cpukit/libcsupport/src/getlogin.c b/cpukit/libcsupport/src/getlogin.c index 8515a75ed5..f98e7ca9e0 100644 --- a/cpukit/libcsupport/src/getlogin.c +++ b/cpukit/libcsupport/src/getlogin.c @@ -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; } |