summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-09-29 14:22:11 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-09-29 14:22:11 +0200
commit536415cf3dba053b0d2294b7f1dc8e34328e795f (patch)
tree5bd199751cfcc575e8d382e13025d6e1ad819009 /runtime
parent5c6eee3e440e486a1b2aeef7eeebb766509d79dc (diff)
downloadrsyslog-536415cf3dba053b0d2294b7f1dc8e34328e795f.tar.gz
rsyslog-536415cf3dba053b0d2294b7f1dc8e34328e795f.tar.xz
rsyslog-536415cf3dba053b0d2294b7f1dc8e34328e795f.zip
bugfix: invalid handling of zero-sized messages
could lead to mis-addressing and potential memory corruption/segfault
Diffstat (limited to 'runtime')
-rw-r--r--runtime/parser.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/parser.c b/runtime/parser.c
index 079bcf5e..7eff0801 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -167,6 +167,7 @@ sanitizeMessage(msg_t *pMsg)
size_t iMaxLine;
assert(pMsg != NULL);
+ assert(pMsg->iLenRawMsg > 0);
# ifdef USE_NETZIP
CHKiRet(uncompressMessage(pMsg));
@@ -288,6 +289,9 @@ rsRetVal parseMsg(msg_t *pMsg)
int lenMsg;
int iPriText;
+ if(pMsg->iLenRawMsg == 0)
+ ABORT_FINALIZE(RS_RET_EMPTY_MSG);
+
CHKiRet(sanitizeMessage(pMsg));
/* we needed to sanitize first, because we otherwise do not have a C-string we can print... */
@@ -295,8 +299,6 @@ rsRetVal parseMsg(msg_t *pMsg)
/* pull PRI */
lenMsg = pMsg->iLenRawMsg;
- if(lenMsg == 0)
- ABORT_FINALIZE(RS_RET_EMPTY_MSG);
msg = pMsg->pszRawMsg;
pri = DEFUPRI;
iPriText = 0;