summaryrefslogtreecommitdiffstats
path: root/runtime/parser.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-10-01 16:30:32 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-10-01 16:30:32 +0200
commit176f773a2e7d29d45e06980e684d293fa3352d72 (patch)
tree341540dbc9b77459410f840022dc75f30d668924 /runtime/parser.c
parent8bab264ba168b5fee36a7b45020e5e2172c74224 (diff)
parente13537ce909e8e6ab0b9d404c1e4870980c6dacf (diff)
downloadrsyslog-176f773a2e7d29d45e06980e684d293fa3352d72.tar.gz
rsyslog-176f773a2e7d29d45e06980e684d293fa3352d72.tar.xz
rsyslog-176f773a2e7d29d45e06980e684d293fa3352d72.zip
Merge branch 'v4-stable' into v4-beta & BUGFIX
Conflicts: configure.ac doc/manual.html runtime/datetime.h runtime/parser.c runtime/rsyslog.h tools/syslogd.c v4-stable had a bug with RFC5424-formatted structured data, which showed was detected by the enhanced automatted testbench of v4-beta.
Diffstat (limited to 'runtime/parser.c')
-rw-r--r--runtime/parser.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/parser.c b/runtime/parser.c
index db11ac5b..466066e7 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -167,6 +167,7 @@ sanitizeMessage(msg_t *pMsg)
uchar szSanBuf[32*1024]; /* buffer used for sanitizing a string */
assert(pMsg != NULL);
+ assert(pMsg->iLenRawMsg > 0);
# ifdef USE_NETZIP
CHKiRet(uncompressMessage(pMsg));
@@ -254,6 +255,7 @@ finalize_it:
RETiRet;
}
+
/* Parse a received message. The object's rawmsg property is taken and
* parsed according to the relevant standards. This can later be
* extended to support configured parsers.
@@ -264,6 +266,11 @@ rsRetVal parseMsg(msg_t *pMsg)
DEFiRet;
uchar *msg;
int pri;
+ int lenMsg;
+ int iPriText;
+
+ if(pMsg->iLenRawMsg == 0)
+ ABORT_FINALIZE(RS_RET_EMPTY_MSG);
CHKiRet(sanitizeMessage(pMsg));
@@ -271,15 +278,17 @@ rsRetVal parseMsg(msg_t *pMsg)
DBGPRINTF("msg parser: flags %x, from '%s', msg '%s'\n", pMsg->msgFlags, getRcvFrom(pMsg), pMsg->pszRawMsg);
/* pull PRI */
- pri = DEFUPRI;
+ lenMsg = pMsg->iLenRawMsg;
msg = pMsg->pszRawMsg;
+ pri = DEFUPRI;
+ iPriText = 0;
if(*msg == '<') {
/* while we process the PRI, we also fill the PRI textual representation
* inside the msg object. This may not be ideal from an OOP point of view,
* but it offers us performance...
*/
pri = 0;
- while(isdigit((int) *++msg)) {
+ while(--lenMsg > 0 && isdigit((int) *++msg)) {
pri = 10 * pri + (*msg - '0');
}
if(*msg == '>')