From: millert Date: Fri, 1 Jul 2016 15:47:15 +0000 (+0000) Subject: Avoid printing f->f_lasttime and/or f->f_prevhost if they are empty. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=13a8eb257b4c0056959924e16a3d8f45ccdffac2;p=openbsd 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@ --- 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;