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.
This commit is contained in:
Kazutaka YOKOTA 1997-03-07 11:04:01 +00:00
parent 6d7977a7cc
commit 719ed69ecf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23494

View File

@ -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);