diff options
| author | Matthew Dillon <dillon@FreeBSD.org> | 1998-12-13 03:42:51 +0000 |
|---|---|---|
| committer | Matthew Dillon <dillon@FreeBSD.org> | 1998-12-13 03:42:51 +0000 |
| commit | 98df703fe0e12bf73506bc7307beaf2b0cf18859 (patch) | |
| tree | cffe64da9658ce8b27fd12feda8c7c125ae3c182 /usr.bin/wall | |
| parent | 4bb8e546c123201a4569ba00b9f9e76916db20e1 (diff) | |
Notes
Diffstat (limited to 'usr.bin/wall')
| -rw-r--r-- | usr.bin/wall/wall.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 04a4823088ca..288bea32c2c4 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)wall.c 8.2 (Berkeley) 11/16/93"; #endif static const char rcsid[] = - "$Id: wall.c,v 1.8 1997/08/25 06:43:22 charnier Exp $"; + "$Id: wall.c,v 1.9 1997/09/15 01:03:16 ache Exp $"; #endif /* not lint */ /* @@ -144,10 +144,10 @@ makemsg(fname) time_t now; FILE *fp; int fd; - char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[15]; + char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[256], tmpname[64]; + + snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); - (void)strcpy(tmpname, _PATH_TMP); - (void)strcat(tmpname, "/wall.XXXXXX"); if (!(fd = mkstemp(tmpname)) || !(fp = fdopen(fd, "r+"))) errx(1, "can't open temporary file"); (void)unlink(tmpname); @@ -167,10 +167,12 @@ makemsg(fname) * in column 80, but that can't be helped. */ (void)fprintf(fp, "\r%79s\r\n", " "); - (void)sprintf(lbuf, "Broadcast Message from %s@%s", + (void)snprintf(lbuf, sizeof(lbuf), + "Broadcast Message from %s@%s", whom, hostname); (void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf); - (void)sprintf(lbuf, " (%s) at %d:%02d ...", ttyname(2), + (void)snprintf(lbuf, sizeof(lbuf), + " (%s) at %d:%02d ...", ttyname(2), lt->tm_hour, lt->tm_min); (void)fprintf(fp, "%-79.79s\r\n", lbuf); } |
