summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-02-22 09:31:10 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-02-22 09:31:10 +0100
commitc577e9c64cec0eebf6b7c3bd964354ab90c045ae (patch)
tree1899b41ccc57b88542e7c9e7a6891cccffdcb721 /tools
parentf764f24baa542796776e76bb5f22fdf9d7e32f5e (diff)
downloadrsyslog-c577e9c64cec0eebf6b7c3bd964354ab90c045ae.tar.gz
rsyslog-c577e9c64cec0eebf6b7c3bd964354ab90c045ae.tar.xz
rsyslog-c577e9c64cec0eebf6b7c3bd964354ab90c045ae.zip
bugfix: message without MSG part could case a segfault
[backported from v5 commit 98d1ed504ec001728955a5bcd7916f64cd85f39f] This actually was a "recent" regression, but I did not realize that it was introduced by the performance optimization in v4-devel. Shame on me for having two devel versions at the same time...
Diffstat (limited to 'tools')
-rw-r--r--tools/syslogd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index db1e9428..3e6d51d3 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1198,8 +1198,6 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
assert(pMsg != NULL);
assert(pMsg->pszRawMsg != NULL);
lenMsg = pMsg->iLenRawMsg - (pMsg->offAfterPRI + 1);
-RUNLOG_VAR("%d", pMsg->offAfterPRI);
-RUNLOG_VAR("%d", lenMsg);
p2parse = pMsg->pszRawMsg + pMsg->offAfterPRI; /* point to start of text, after PRI */
/* Check to see if msg contains a timestamp. We start by assuming
@@ -1255,16 +1253,16 @@ RUNLOG_VAR("%d", lenMsg);
bTAGCharDetected = 0;
if(lenMsg > 0 && flags & PARSE_HOSTNAME) {
i = 0;
- while(lenMsg > 0 && (isalnum(p2parse[i]) || p2parse[i] == '.' || p2parse[i] == '.'
+ while(i < lenMsg && (isalnum(p2parse[i]) || p2parse[i] == '.' || p2parse[i] == '.'
|| p2parse[i] == '_' || p2parse[i] == '-') && i < CONF_TAG_MAXSIZE) {
bufParseHOSTNAME[i] = p2parse[i];
++i;
- --lenMsg;
}
if(i > 0 && p2parse[i] == ' ' && isalnum(p2parse[i-1])) {
/* we got a hostname! */
p2parse += i + 1; /* "eat" it (including SP delimiter) */
+ lenMsg -= i + 1;
bufParseHOSTNAME[i] = '\0';
MsgSetHOSTNAME(pMsg, bufParseHOSTNAME, i);
}