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. --- syslogd.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'syslogd.c') 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