diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rwho/rwho.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/rwho/rwho.c b/usr.bin/rwho/rwho.c index 353e280be63..87a34951c5a 100644 --- a/usr.bin/rwho/rwho.c +++ b/usr.bin/rwho/rwho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rwho.c,v 1.2 1996/06/26 05:39:00 deraadt Exp $ */ +/* $OpenBSD: rwho.c,v 1.3 1996/08/30 11:10:32 deraadt Exp $ */ /* * Copyright (c) 1983 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)rwho.c 5.5 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$OpenBSD: rwho.c,v 1.2 1996/06/26 05:39:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rwho.c,v 1.3 1996/08/30 11:10:32 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -50,11 +50,12 @@ static char rcsid[] = "$OpenBSD: rwho.c,v 1.2 1996/06/26 05:39:00 deraadt Exp $" #include <protocols/rwhod.h> #include <stdio.h> #include <string.h> +#include <unistd.h> +#include <stdlib.h> DIR *dirp; struct whod wd; -int utmpcmp(); #define NUSERS 1000 struct myutmp { char myhost[MAXHOSTNAMELEN]; @@ -63,16 +64,19 @@ struct myutmp { } myutmp[NUSERS]; int nusers; +int utmpcmp __P((struct myutmp *, struct myutmp *)); + #define WHDRSIZE (sizeof (wd) - sizeof (wd.wd_we)) /* * this macro should be shared with ruptime. */ #define down(w,now) ((now) - (w)->wd_recvtime > 11 * 60) -char *ctime(), *strcpy(); +char *ctime(); time_t now; int aflg; +int main(argc, argv) int argc; char **argv; @@ -104,7 +108,7 @@ main(argc, argv) } mp = myutmp; (void)time(&now); - while (dp = readdir(dirp)) { + while ((dp = readdir(dirp))) { if (dp->d_ino == 0 || strncmp(dp->d_name, "whod.", 5)) continue; f = open(dp->d_name, O_RDONLY); @@ -131,7 +135,9 @@ main(argc, argv) exit(1); } mp->myutmp = we->we_utmp; mp->myidle = we->we_idle; - (void) strcpy(mp->myhost, w->wd_hostname); + (void) strncpy(mp->myhost, w->wd_hostname, + sizeof(mp->myhost)-1); + mp->myhost[sizeof(mp->myhost)-1] = '\0'; nusers++; we++; mp++; } (void) close(f); @@ -173,6 +179,7 @@ main(argc, argv) exit(0); } +int utmpcmp(u1, u2) struct myutmp *u1, *u2; { |