Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!hplabs!sri-unix!mrose@uci-750a From: mrose%uci-750a@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: bug in syslog(3) Message-ID: <15712@sri-arpa.UUCP> Date: Wed, 18-Jan-84 22:49:53 EST Article-I.D.: sri-arpa.15712 Posted: Wed Jan 18 22:49:53 1984 Date-Received: Sat, 21-Jan-84 01:38:40 EST Lines: 54 From: Marshall Rose Description: If the format string you give to syslog() contains a '%' escape other than a '%m', then the format string is truncated after that escape and the resulting output in the syslog file looks very wierd. This bug makes syslog() virtually useless if you like to put lots of information in a single line. Repeat-By: Run the following program, wait a while for some other process to send something to the syslog daemon, and then check out the file. You'll see something like this: Jan 17 17:39:12 localhost: 4222 foo: argc=1<8>4231 sendmail: connected to uci-750b Note how the syslog daemon got real confused on that one... #include main (argc, argv) char **argv; { openlog ("foo", LOG_PID); syslog (LOG_INFO, "argc=%d *argv=%s", argc, *argv); } Fix: The code that expands '%m' in the source format string prematurely embeds a null in the target format string. The solution is not to do this (obviously). Actually, a better fix would be to make the daemon work correctly regardless of the message that it received. That's not done here though. *** _syslog.c Tue Jan 17 17:27:49 1984 --- syslog.c Tue Jan 17 17:27:55 1984 *************** *** 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; continue; } if ((unsigned)errno > sys_nerr)