From d3a88c693c9d4ce0f5d0964d6aac169fd14afb67 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Sep 2007 08:50:41 +0000 Subject: added code to handle situations where senders send us messages ending with a NUL character. It is now simply removed. This also caused trailing LF reduction to fail, when it was followed by such a NUL. This is now also handled. --- ChangeLog | 8 +++++++- configure.ac | 4 ++-- syslogd.c | 20 ++++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 560c260b..b2319df1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ ---------------------------------------------------------------------------- +--------------------------------------------------------------------------- +Version 1.19.7 (rgerhards), 2007-09-1? +- added code to handle situations where senders send us messages ending with + a NUL character. It is now simply removed. This also caused trailing LF + reduction to fail, when it was followed by such a NUL. This is now also + handled. +--------------------------------------------------------------------------- Version 1.19.6 (rgerhards), 2007-09-11 - applied patch by varmojfekoj to change signal handling to the new sigaction API set (replacing the depreciated signal() calls and its diff --git a/configure.ac b/configure.ac index 0e295b17..aae19485 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[1.19.6],[rsyslog@lists.adiscon.com.]) -AM_INIT_AUTOMAKE(rsyslog, 1.19.6) +AC_INIT([rsyslog],[1.19.7],[rsyslog@lists.adiscon.com.]) +AM_INIT_AUTOMAKE(rsyslog, 1.19.7) AC_CONFIG_SRCDIR([syslogd.c]) AC_CONFIG_HEADER([config.h]) diff --git a/syslogd.c b/syslogd.c index 093020d8..d45e561f 100644 --- a/syslogd.c +++ b/syslogd.c @@ -2023,13 +2023,28 @@ void printchopped(char *hname, char *msg, int len, int fd, int bParseHost) dbgprintf("Message length: %d, File descriptor: %d.\n", len, fd); - /* we first check if we need to drop trailing LFs, which often make + /* we first check if we have a NUL character at the very end of the + * message. This seems to be a frequent problem with a number of senders. + * So I have now decided to drop these NULs. However, if they are intentional, + * that may cause us some problems, e.g. with syslog-sign. On the other hand, + * current code always has problems with intentional NULs (as it needs to escape + * them to prevent problems with the C string libraries), so that does not + * really matter. Just to be on the save side, we'll log destruction of such + * NULs in the debug log. + * rgerhards, 2007-09-14 + */ + if(*(msg + len - 1) == '\0') { + dbgprintf("dropped NUL at very end of message\n"); + len--; + } + + /* then we check if we need to drop trailing LFs, which often make * their way into syslog messages unintentionally. In order to remain * compatible to recent IETF developments, we allow the user to * turn on/off this handling. rgerhards, 2007-07-23 */ if(bDropTrailingLF && *(msg + len - 1) == '\n') { - *(msg + len - 1) = '\0'; + dbgprintf("dropped LF at very end of message (DropTrailingLF is set)\n"); len--; } @@ -4316,6 +4331,7 @@ static void init(void) } } + dbgprintf("rsyslog %s.\n", VERSION); dbgprintf("Called init.\n"); /* Close all open log files and free log descriptor array. */ -- cgit v1.2.3