Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site spool.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!uwvax!spool!root From: root@spool.UUCP Newsgroups: net.bugs.4bsd Subject: bug in 4.2 /usr/src/lib/libc/gen/syslog.c [syslog(3)] FIX Message-ID: <102@spool.UUCP> Date: Mon, 5-Aug-85 17:40:18 EDT Article-I.D.: spool.102 Posted: Mon Aug 5 17:40:18 1985 Date-Received: Wed, 7-Aug-85 00:52:23 EDT Distribution: net Organization: U of Wisconsin CS Dept Lines: 52 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 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) ***************