diff options
| author | Warner Losh <imp@FreeBSD.org> | 2001-03-01 05:43:12 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2001-03-01 05:43:12 +0000 |
| commit | 6a20d55a591484ce93ad7002606c9ca4dbbd7ebb (patch) | |
| tree | 8d6220693e80496b0fa54913fd1d6a004daf69e1 /usr.bin/wall/ttymsg.c | |
| parent | 45d80087483bd81f5ba69a7bbb3b5b5ba954d97c (diff) | |
Notes
Diffstat (limited to 'usr.bin/wall/ttymsg.c')
| -rw-r--r-- | usr.bin/wall/ttymsg.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/usr.bin/wall/ttymsg.c b/usr.bin/wall/ttymsg.c index a42ef412af985..3dccfbc813358 100644 --- a/usr.bin/wall/ttymsg.c +++ b/usr.bin/wall/ttymsg.c @@ -59,26 +59,23 @@ static const char rcsid[] = * ignored (exclusive-use, lack of permission, etc.). */ char * -ttymsg(iov, iovcnt, line, tmout) - struct iovec *iov; - int iovcnt; - char *line; - int tmout; +ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) { + struct iovec localiov[7]; + int cnt, fd, left, wret; static char device[MAXNAMLEN] = _PATH_DEV; static char errbuf[1024]; - register int cnt, fd, left, wret; - struct iovec localiov[7]; - int forked = 0; + int forked; + forked = 0; if (iovcnt > sizeof(localiov) / sizeof(localiov[0])) return ("too many iov's (change code in wall/ttymsg.c)"); - (void) strcpy(device + sizeof(_PATH_DEV) - 1, line); + strlcat(device, line, sizeof(device)); if (strchr(device + sizeof(_PATH_DEV) - 1, '/')) { /* A slash is an attempt to break security... */ - (void) snprintf(errbuf, sizeof(errbuf), "'/' in \"%s\"", - device); + (void) snprintf(errbuf, sizeof(errbuf), + "Too many '/' in \"%s\"", device); return (errbuf); } @@ -89,8 +86,8 @@ ttymsg(iov, iovcnt, line, tmout) if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) { if (errno == EBUSY || errno == EACCES) return (NULL); - (void) snprintf(errbuf, sizeof(errbuf), - "%s: %s", device, strerror(errno)); + (void) snprintf(errbuf, sizeof(errbuf), "%s: %s", device, + strerror(errno)); return (errbuf); } @@ -104,7 +101,7 @@ ttymsg(iov, iovcnt, line, tmout) if (wret >= 0) { left -= wret; if (iov != localiov) { - bcopy(iov, localiov, + bcopy(iov, localiov, iovcnt * sizeof(struct iovec)); iov = localiov; } |
