summaryrefslogtreecommitdiff
path: root/src/who.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-07-15 18:18:03 +0200
committerJim Meyering <meyering@redhat.com>2012-07-15 19:11:45 +0200
commitac00d23e1a90dc5a8cd0f6de0e61eb401d5089d5 (patch)
treee94876b4676c65ad8b8fa84d9f5d7320944ba5df /src/who.c
parente380221333f4efd8d49b29b2690375c36eb90505 (diff)
downloadcoreutils-ac00d23e1a90dc5a8cd0f6de0e61eb401d5089d5.tar.xz
pinky,who: fix bug in latest change
* src/system.h (stzncpy): New function. * src/pinky.c (print_entry): Use stzncpy, not stpncpy. The latter does not NUL-terminate. I assumed that strncpy was the only function with such a horrible API. Today I learned that stpncpy also may not NUL-terminate its result. The bugs were introduced in commit v8.17-48-gf79263d. * src/who.c (print_user): Likewise. Thanks to Erik Auerswald for spotting my error.
Diffstat (limited to 'src/who.c')
-rw-r--r--src/who.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/who.c b/src/who.c
index 3ad800429..00a6e37de 100644
--- a/src/who.c
+++ b/src/who.c
@@ -350,7 +350,7 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime)
absolute file name in ut_line. */
if ( ! IS_ABSOLUTE_FILE_NAME (utmp_ent->ut_line))
p = stpcpy (p, DEV_DIR_WITH_TRAILING_SLASH);
- stpncpy (p, utmp_ent->ut_line, sizeof (utmp_ent->ut_line));
+ stzncpy (p, utmp_ent->ut_line, sizeof (utmp_ent->ut_line));
if (stat (line, &stats) == 0)
{
@@ -376,7 +376,7 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime)
char *display = NULL;
/* Copy the host name into UT_HOST, and ensure it's nul terminated. */
- stpncpy (ut_host, utmp_ent->ut_host, sizeof (utmp_ent->ut_host));
+ stzncpy (ut_host, utmp_ent->ut_host, sizeof (utmp_ent->ut_host));
/* Look for an X display. */
display = strchr (ut_host, ':');