summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-09-14 08:50:41 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-09-14 08:50:41 +0000
commitd3a88c693c9d4ce0f5d0964d6aac169fd14afb67 (patch)
tree76443038572bf79f4cb583a403d73880393c7165 /syslogd.c
parent08955213b79f8c4137539f0f6b7af002f0a00102 (diff)
downloadrsyslog-d3a88c693c9d4ce0f5d0964d6aac169fd14afb67.tar.gz
rsyslog-d3a88c693c9d4ce0f5d0964d6aac169fd14afb67.tar.xz
rsyslog-d3a88c693c9d4ce0f5d0964d6aac169fd14afb67.zip
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.
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c20
1 files changed, 18 insertions, 2 deletions
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. */