PR/39912: Jukka Salmi: Logger eats the first word because of incorrect

syslogp invocation.
This commit is contained in:
christos 2008-11-13 15:51:07 +00:00
parent f34e8d4f6b
commit d5e5a2c9eb

View File

@ -1,4 +1,4 @@
/* $NetBSD: logger.c,v 1.12 2008/10/31 20:53:46 christos Exp $ */
/* $NetBSD: logger.c,v 1.13 2008/11/13 15:51:07 christos Exp $ */
/*
* Copyright (c) 1983, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
#if 0
static char sccsid[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: logger.c,v 1.12 2008/10/31 20:53:46 christos Exp $");
__RCSID("$NetBSD: logger.c,v 1.13 2008/11/13 15:51:07 christos Exp $");
#endif /* not lint */
#include <errno.h>
@ -119,11 +119,11 @@ main(int argc, char *argv[])
for (p = buf, endp = buf + sizeof(buf) - 2; *argv != NULL;) {
len = strlen(*argv);
if (p + len > endp && p > buf) {
syslogp(pri, "%s", msgid, sd, buf);
syslogp(pri, msgid, sd, "%s", buf);
p = buf;
}
if (len > sizeof(buf) - 1)
syslogp(pri, "%s", msgid, sd, *argv++);
syslogp(pri, msgid, sd, "%s", *argv++);
else {
if (p != buf)
*p++ = ' ';
@ -132,13 +132,13 @@ main(int argc, char *argv[])
}
}
if (p != buf)
syslogp(pri, "%s", msgid, sd, buf);
syslogp(pri, msgid, sd, "%s", buf);
} else /* TODO: allow syslog-protocol messages from file/stdin
* but that will require parsing the line to split
* it into three fields.
*/
while (fgets(buf, sizeof(buf), stdin) != NULL)
syslogp(pri, "%s", msgid, sd, buf);
syslogp(pri, msgid, sd, "%s", buf);
exit(EXIT_SUCCESS);
/* NOTREACHED */