summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-07-01 15:47:16 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-07-01 15:47:16 +0000
commitc512e63c7113e35452d567195200cc9f851099cf (patch)
tree54a6c85de5499940beafff85dad075d86dfd2459 /usr.sbin
parente1619df4f7dadb4bd85619a2b3c3fbb3b766f5c0 (diff)
Avoid printing f->f_lasttime and/or f->f_prevhost if they are empty.
This fixes a long-standing issue where syslogd would print 15 NUL bytes followed by two blank spaces before the log message for warnings generated while parsing syslog.conf. OK bluhm@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index e916ef12e1c..a3f83d614d3 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.206 2016/07/01 15:00:48 millert Exp $ */
+/* $OpenBSD: syslogd.c,v 1.207 2016/07/01 15:47:15 millert Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -1738,20 +1738,36 @@ fprintlog(struct filed *f, int flags, char *msg)
v->iov_base = "";
v->iov_len = 0;
v++;
- } else {
+ } else if (f->f_lasttime[0] != '\0') {
v->iov_base = f->f_lasttime;
v->iov_len = 15;
v++;
v->iov_base = " ";
v->iov_len = 1;
v++;
+ } else {
+ v->iov_base = "";
+ v->iov_len = 0;
+ v++;
+ v->iov_base = "";
+ v->iov_len = 0;
+ v++;
+ }
+ if (f->f_prevhost[0] != '\0') {
+ v->iov_base = f->f_prevhost;
+ v->iov_len = strlen(v->iov_base);
+ v++;
+ v->iov_base = " ";
+ v->iov_len = 1;
+ v++;
+ } else {
+ v->iov_base = "";
+ v->iov_len = 0;
+ v++;
+ v->iov_base = "";
+ v->iov_len = 0;
+ v++;
}
- v->iov_base = f->f_prevhost;
- v->iov_len = strlen(v->iov_base);
- v++;
- v->iov_base = " ";
- v->iov_len = 1;
- v++;
if (msg) {
v->iov_base = msg;