diff options
author | yokota <yokota@FreeBSD.org> | 1997-03-07 11:04:01 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 1997-03-07 11:04:01 +0000 |
commit | e2b0343661ea487838ed92e8f8eadd0edd4fab63 (patch) | |
tree | 18791ca1d5940fb83591e6e8c35ee32257ab3737 | |
parent | 479436ac99420a9f21448ceff38e56f9891b74de (diff) | |
download | FreeBSD-src-e2b0343661ea487838ed92e8f8eadd0edd4fab63.zip FreeBSD-src-e2b0343661ea487838ed92e8f8eadd0edd4fab63.tar.gz |
Made sure the string formated by strftime() is properly
null-terminated.
Fixed a wrong if statement which should test a string is
empty where in fact it tested the string pointer was NULL.
Should go to RELENG_2_1 and RELENG_2_2.
Reviewed by guido@freebsd.org.
-rw-r--r-- | usr.bin/who/who.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/who/who.c b/usr.bin/who/who.c index 3060881..e16a7b9 100644 --- a/usr.bin/who/who.c +++ b/usr.bin/who/who.c @@ -87,7 +87,7 @@ main(argc, argv) if (t = rindex(p, '/')) p = t + 1; while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1) - if (usr.ut_name && !strcmp(usr.ut_line, p)) { + if (*usr.ut_name && !strcmp(usr.ut_line, p)) { output(&usr); exit(0); } @@ -116,6 +116,7 @@ output(up) (void)printf("%-*.*s %-*.*s", UT_NAMESIZE, UT_NAMESIZE, up->ut_name, UT_LINESIZE, UT_LINESIZE, up->ut_line); (void)strftime(buf, sizeof(buf), "%c", localtime(&up->ut_time)); + buf[sizeof(buf) - 1] = '\0'; (void)printf("%.12s", buf + 4); if (*up->ut_host) printf("\t(%.*s)", UT_HOSTSIZE, up->ut_host); |