From 4f90578a4f0cdb2e9f708d924dd67e6a5b9cd289 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 7 Jan 1994 00:06:38 +0000 Subject: [PATCH] * who.c (print_entry): Prepend `/dev/' only if ut_line is not already an absolute filename. Just to be safe. --- src/who.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/who.c b/src/who.c index 1e04699..78fb0ce 100644 --- a/src/who.c +++ b/src/who.c @@ -287,9 +287,20 @@ print_entry (this) char line[sizeof (this->ut_line) + DEV_DIR_LEN + 1]; - strcpy(line, DEV_DIR_WITH_TRAILING_SLASH); - strncpy (line + DEV_DIR_LEN, this->ut_line, sizeof (this->ut_line)); - line[DEV_DIR_LEN + sizeof (this->ut_line)] = '\0'; + /* Copy ut_line into LINE, prepending `/dev/' if ut_line is not + already an absolute pathname. Some system may put the full, + absolute pathname in ut_line. */ + if (this->ut_line[0] == '/') + { + strncpy (line, this->ut_line, sizeof (this->ut_line)); + line[sizeof (this->ut_line)] = '\0'; + } + else + { + strcpy(line, DEV_DIR_WITH_TRAILING_SLASH); + strncpy (line + DEV_DIR_LEN, this->ut_line, sizeof (this->ut_line)); + line[DEV_DIR_LEN + sizeof (this->ut_line)] = '\0'; + } if (stat (line, &stats) == 0) { -- 2.7.4