diff options
| author | David Malone <dwmalone@FreeBSD.org> | 2004-05-29 23:40:30 +0000 |
|---|---|---|
| committer | David Malone <dwmalone@FreeBSD.org> | 2004-05-29 23:40:30 +0000 |
| commit | 75030d06769539cf2b6ccf6cb237fe8917efccd2 (patch) | |
| tree | bc51e465bd66fb9ec4e5b53ab647c0565e936cde /usr.sbin/syslogd | |
| parent | 6f8c264082f558311f22a3d63b81b4fe080c26b2 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/syslogd')
| -rw-r--r-- | usr.sbin/syslogd/syslogd.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 146dfb02eb134..6c5106eb9e0b9 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1236,7 +1236,9 @@ wallmsg(struct filed *f, struct iovec *iov) while (fread((char *)&ut, sizeof(ut), 1, uf) == 1) { if (ut.ut_name[0] == '\0') continue; - (void)strlcpy(line, ut.ut_line, sizeof(line)); + /* We must use strncpy since ut_* may not be NUL terminated. */ + strncpy(line, ut.ut_line, sizeof(line) - 1); + line[sizeof(line) - 1] = '\0'; if (f->f_type == F_WALL) { if ((p = ttymsg(iov, 7, line, TTYMSGTIME)) != NULL) { errno = 0; /* already in msg */ @@ -1544,9 +1546,8 @@ init(int signo) prog[i] = 0; continue; } - for (p = strchr(cline, '\0'); isspace(*--p);) - continue; - *++p = '\0'; + for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) + cline[i] = '\0'; f = (struct filed *)calloc(1, sizeof(*f)); if (f == NULL) { logerror("calloc"); @@ -1724,6 +1725,10 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) pri = LOG_PRIMASK + 1; pri_cmp = PRI_LT | PRI_EQ | PRI_GT; } else { + /* Ignore trailing spaces. */ + for (i = strlen(buf) - 1; i >= 0 && buf[i] == ' '; i--) + buf[i] = '\0'; + pri = decode(buf, prioritynames); if (pri < 0) { (void)snprintf(ebuf, sizeof ebuf, |
