root@spool.UUCP (08/06/85)
Index: /usr/src/lib/libc/gen/syslog.c 4.2BSD Description: The 4.2 syslog routine in the C library doesn't log correctly because when it is processing '%' formatters in the the format string, it updates its buffer pointer too many times leaving a null character in the string. This causes the message to be incomplete and /etc/syslog doesn't write the message out until it receives the whole message terminated by a newline. Repeat-By: Run the following program: #include <syslog.h> main() { openlog("testlog", LOG_PID); syslog(LOG_INFO, "test %s with %s", "message", "arguments"); closelog(); } This message should go into your /usr/spool/mqueue/syslog (or wherever you keep this logfile), however, you see that the message doesn't make it. When the next message comes in from sendmail, it will be garbled with the incomplete message tacked on to the beginning. Fix: Remove the auto-increment when assigning a NUL to the end of the buffer. *** syslog.c.old Mon Aug 5 16:27:30 1985 --- syslog.c Mon Aug 5 16:27:59 1985 *************** *** 70,76 } c = *f++; if (c != 'm') { ! *b++ = '%', *b++ = c, *b++ = '\0'; continue; } if ((unsigned)errno > sys_nerr) --- 70,76 ----- } c = *f++; if (c != 'm') { ! *b++ = '%', *b++ = c, *b = 0; continue; } if ((unsigned)errno > sys_nerr) ***************