summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordds <dds@FreeBSD.org>2004-05-10 17:12:52 +0000
committerdds <dds@FreeBSD.org>2004-05-10 17:12:52 +0000
commit9498b96a34223c48bc0f1e186c7fae665bbe522f (patch)
treefa51c27f23ef454fc75f997c7a325729cd80a0c2
parent5994ff7b4c470c55ddf16a452334d6deaf635f27 (diff)
downloadFreeBSD-src-9498b96a34223c48bc0f1e186c7fae665bbe522f.zip
FreeBSD-src-9498b96a34223c48bc0f1e186c7fae665bbe522f.tar.gz
Remove a trailing newline, to behave as documented in syslog(3):
"A trailing newline is added if none is present." The code in syslogd, stderr, and console output always adds a newline at the EOL. However, the existing code never actually removed a trailing newline, and apparently relied on syslogd to convert it into a space character. Thus, the existing newline was converted to a trailing space at the EOL by syslogd, while stderr, and console output resulted in an empty line. MFC after: 2 weeks
-rw-r--r--lib/libc/gen/syslog.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 8c5a2e3..2c16d73 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -222,6 +222,10 @@ vsyslog(pri, fmt, ap)
cnt = sizeof(tbuf) - tbuf_cookie.left;
+ /* Remove a trailing newline */
+ if (tbuf[cnt - 1] == '\n')
+ cnt--;
+
/* Output to stderr if requested. */
if (LogStat & LOG_PERROR) {
struct iovec iov[2];
OpenPOWER on IntegriCloud