bug in syslog(3)
mrose%uci-750a at sri-unix.UUCP
mrose%uci-750a at sri-unix.UUCP
Thu Jan 19 13:49:53 AEST 1984
From: Marshall Rose <mrose at uci-750a>
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 <syslog.h>
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)
More information about the Comp.unix.wizards
mailing list