diff --git a/usr.sbin/dntpd/log.c b/usr.sbin/dntpd/log.c index 5e0291b..09e9798 100644 --- a/usr.sbin/dntpd/log.c +++ b/usr.sbin/dntpd/log.c @@ -113,21 +113,30 @@ vlogline(int level, int newline, const char *ctl, va_list va) { static char line_build[1024]; static int line_index; - int priority; + int priority, used = 0; + va_list va2; /* * Output to stderr directly but build the log line for syslog. */ if (level <= debug_level) { if (log_stderr) { + used = 1; + va_copy(va2, va); vfprintf(stderr, ctl, va); if (newline) fprintf(stderr, "\n"); fflush(stderr); } if (debug_opt == 0) { - vsnprintf(line_build + line_index, sizeof(line_build) - line_index, - ctl, va); + if (used == 0) + vsnprintf(line_build + line_index, + sizeof(line_build) - line_index, + ctl, va); + else + vsnprintf(line_build + line_index, + sizeof(line_build) - line_index, + ctl, va2); line_index += strlen(line_build + line_index); if (line_index && line_build[line_index-1] == '\n') { newline = 1;