OK bluhm@
On Fri, Jul 01, 2016 at 07:20:25AM -0600, Todd C. Miller wrote:
> If syslogd encounters an error while processing syslog.conf the
> error message goes to the console since logging has not been setup
> yet.
>
> However, in this case, neither f->f_lasttime nor f->f_prevhost are
> set. This results in 15 NUL bytes and two space characters preceding
> the actual message on the console.
>
> The trivial fix is to check for the empty strings in fprintlog().
> Alternately, we could set the timestamp and hostname in logmsg()
> before calling fprintlog() in the !Initialized case.
>
> - todd
>
> Index: usr.sbin/syslogd/syslogd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.205
> diff -u -p -u -r1.205 syslogd.c
> --- usr.sbin/syslogd/syslogd.c 2 Apr 2016 19:55:10 -0000 1.205
> +++ usr.sbin/syslogd/syslogd.c 1 Jul 2016 13:06:04 -0000
> @@ -1738,20 +1738,36 @@ fprintlog(struct filed *f, int flags, ch
> 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;