Skip to content

Commit ea84f61

Browse files
committed
coreutils/who.c: use of potentially dangerous function (fix 17)
Alerts: mirror#59 text data bss dec hex filename 1155501 18124 2056 1175681 11f081 busybox 1155846 18124 2056 1176026 11f1da busybox Total 17 fixes +345 Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
1 parent fc36bf2 commit ea84f61

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

coreutils/who.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ int who_main(int argc UNUSED_PARAM, char **argv)
114114
struct utmpx *ut;
115115
unsigned opt;
116116
const char *fmt = "%s";
117+
char tbuf[CTIME_BUF_MAXLEN];
117118

118119
opt = getopt32(argv, do_who ? "^" "aH" "\0" "=0": "^" "" "\0" "=0");
119120
if ((opt & 2) || do_w) /* -H or we are w */
@@ -153,7 +154,7 @@ int who_main(int argc UNUSED_PARAM, char **argv)
153154
// TODO: with LANG=en_US.UTF-8, who from coreutils 8.25 shows
154155
// TIME col as "2017-04-06 18:47" (the default format is "Apr 6 18:47").
155156
// The former format looks saner to me. Switch to it unconditionally?
156-
ctime(&seconds) + 4,
157+
ctime_r(&seconds,tbuf) + 4,
157158
(int)sizeof(ut->ut_host), ut->ut_host
158159
);
159160
} else {

0 commit comments

Comments
 (0)