This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/963] New: syslog() does not always NL terminate messages
- From: "bazsi at balabit dot hu" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 23 May 2005 15:48:14 -0000
- Subject: [Bug libc/963] New: syslog() does not always NL terminate messages
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
The syslog() subroutines in libc support both SOCK_STREAM and SOCK_DGRAM sockets
to fire off messages to syslogd.
When SOCK_STREAM sockets are used (default in old syslogds and preferred in
syslog-ng) lines should always be terminated by some record terminator
character or otherwise the receiving end will have no means to reconstruct
line structure.
According to the man page for syslog() an NL character is automatically
added to messages that miss one:
"... A trailing newline is added when needed."
This is however not true, unless LOG_PERROR is specified as well:
...
/* Output to stderr if requested. */
if (LogStat & LOG_PERROR) {
struct iovec iov[2];
register struct iovec *v = iov;
v->iov_base = buf + msgoff;
v->iov_len = bufsize - msgoff;
/* Append a newline if necessary. */
if (buf[bufsize - 1] != '\n')
{
++v;
v->iov_base = (char *) "\n";
v->iov_len = 1;
}
(void)__writev(STDERR_FILENO, iov, v - iov + 1);
}
When using SOCK_STREAM sockets with applications that do not properly terminate
their messages with NL, lines will be folded together by the system logging
process.
The proper fix would be to move the check for NL out of the LOG_PERROR block
and always add the NL if it is not present.
--
Summary: syslog() does not always NL terminate messages
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: bazsi at balabit dot hu
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=963
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.