summaryrefslogtreecommitdiffstats
path: root/tools/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-10-09 14:48:25 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-10-09 14:48:25 +0200
commit3ed4b2cd3ebaf6f4c377ba2e03ef52c2e8a985b6 (patch)
tree8b76bc61e81809659f8b4eabfd9f8f6d2381b06f /tools/syslogd.c
parentec56b763b83677d1e9cd02a7ae610caf62e902bb (diff)
downloadrsyslog-3ed4b2cd3ebaf6f4c377ba2e03ef52c2e8a985b6.tar.gz
rsyslog-3ed4b2cd3ebaf6f4c377ba2e03ef52c2e8a985b6.tar.xz
rsyslog-3ed4b2cd3ebaf6f4c377ba2e03ef52c2e8a985b6.zip
bugfix: potential segfault on messages with empty MSG part.
This was a recently introduced regression.
Diffstat (limited to 'tools/syslogd.c')
-rw-r--r--tools/syslogd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 0f4f8a23..3dc2d230 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1205,8 +1205,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
@@ -1262,16 +1260,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);
}