diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 15:47:13 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 15:47:13 +0000 |
commit | 1e46612221e29a3f44b51938a54918044e96afd0 (patch) | |
tree | 2117e55710cb70b7cc4f387766cc0e5d2ecf9ae2 /usr.bin/write/write.c | |
parent | a50175212238135f4447473edea4d8c46290faa2 (diff) |
a few more strlcpy
Diffstat (limited to 'usr.bin/write/write.c')
-rw-r--r-- | usr.bin/write/write.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c index 52707f44f98..d086ce6550a 100644 --- a/usr.bin/write/write.c +++ b/usr.bin/write/write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: write.c,v 1.18 2002/12/09 08:15:29 deraadt Exp $ */ +/* $OpenBSD: write.c,v 1.19 2003/03/13 15:47:12 deraadt Exp $ */ /* $NetBSD: write.c,v 1.5 1995/08/31 21:48:32 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)write.c 8.2 (Berkeley) 4/27/95"; #endif -static char *rcsid = "$OpenBSD: write.c,v 1.18 2002/12/09 08:15:29 deraadt Exp $"; +static char *rcsid = "$OpenBSD: write.c,v 1.19 2003/03/13 15:47:12 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -68,7 +68,7 @@ static char *rcsid = "$OpenBSD: write.c,v 1.18 2002/12/09 08:15:29 deraadt Exp $ void done(int sig); void do_write(char *, char *, uid_t); void wr_fputs(char *); -void search_utmp(char *, char *, char *, uid_t); +void search_utmp(char *, char *, int, char *, uid_t); int term_chk(char *, int *, time_t *, int); int utmp_chk(char *, char *); @@ -103,7 +103,7 @@ main(int argc, char **argv) /* check args */ switch (argc) { case 2: - search_utmp(argv[1], tty, mytty, myuid); + search_utmp(argv[1], tty, sizeof tty, mytty, myuid); do_write(tty, mytty, myuid); break; case 3: @@ -165,7 +165,7 @@ utmp_chk(char *user, char *tty) * writing from, unless that's the only terminal with messages enabled. */ void -search_utmp(char *user, char *tty, char *mytty, uid_t myuid) +search_utmp(char *user, char *tty, int ttyl, char *mytty, uid_t myuid) { struct utmp u; time_t bestatime, atime; @@ -194,7 +194,7 @@ search_utmp(char *user, char *tty, char *mytty, uid_t myuid) ++nttys; if (atime > bestatime) { bestatime = atime; - (void)strcpy(tty, atty); + (void)strlcpy(tty, atty, ttyl); } } @@ -203,7 +203,7 @@ search_utmp(char *user, char *tty, char *mytty, uid_t myuid) errx(1, "%s is not logged in", user); if (nttys == 0) { if (user_is_me) { /* ok, so write to yourself! */ - (void)strcpy(tty, mytty); + (void)strlcpy(tty, mytty, ttyl); return; } errx(1, "%s has messages disabled", user); @@ -265,7 +265,7 @@ do_write(char *tty, char *mytty, uid_t myuid) /* print greeting */ if (gethostname(host, sizeof(host)) < 0) - (void)strcpy(host, "???"); + (void)strlcpy(host, "???", sizeof host); now = time((time_t *)NULL); nows = ctime(&now); nows[16] = '\0'; |