diff options
author | Jim Meyering <jim@meyering.net> | 1994-01-07 00:06:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-01-07 00:06:38 +0000 |
commit | 4f90578a4f0cdb2e9f708d924dd67e6a5b9cd289 (patch) | |
tree | e6acc14527335adc52d86237e8cd3f2266862a76 /src/who.c | |
parent | 5bed1ce3db1e36571cf796e371f38ae437daca89 (diff) | |
download | coreutils-4f90578a4f0cdb2e9f708d924dd67e6a5b9cd289.tar.xz |
* who.c (print_entry): Prepend `/dev/' only if ut_line is not
already an absolute filename. Just to be safe.
Diffstat (limited to 'src/who.c')
-rw-r--r-- | src/who.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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) { |