summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-18 17:48:11 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-18 17:48:11 +0200
commitf33dd51c802a8d49839aa73fb9167d8bc31ea912 (patch)
treee9ab40604c50449f46c2af724858bcc245b234f6
parent2de4964affabc1ccf61bc72426a468fc871a54d0 (diff)
downloadrsyslog-f33dd51c802a8d49839aa73fb9167d8bc31ea912.tar.gz
rsyslog-f33dd51c802a8d49839aa73fb9167d8bc31ea912.tar.xz
rsyslog-f33dd51c802a8d49839aa73fb9167d8bc31ea912.zip
fixed abort condition with oversize tags
this was a regression I introduced this afternoon
-rw-r--r--runtime/msg.c33
-rw-r--r--runtime/msg.h1
-rw-r--r--template.c1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/testsuites/oversizeTag-1.parse13
5 files changed, 16 insertions, 23 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 507d041e..4b7a0ad4 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -1321,13 +1321,17 @@ void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf)
freeTAG(pMsg);
pMsg->iLenTAG = lenBuf;
- if(pMsg->iLenTAG < CONF_RAWMSG_BUFSIZE) {
+ if(pMsg->iLenTAG < CONF_TAG_BUFSIZE) {
/* small enough: use fixed buffer (faster!) */
pBuf = pMsg->TAG.szBuf;
- } else if((pBuf = (uchar*) malloc(pMsg->iLenTAG + 1)) == NULL) {
- /* truncate message, better than completely loosing it... */
- pBuf = pMsg->TAG.szBuf;
- pMsg->iLenTAG = CONF_RAWMSG_BUFSIZE - 1;
+ } else {
+ if((pBuf = (uchar*) malloc(pMsg->iLenTAG + 1)) == NULL) {
+ /* truncate message, better than completely loosing it... */
+ pBuf = pMsg->TAG.szBuf;
+ pMsg->iLenTAG = CONF_TAG_BUFSIZE - 1;
+ } else {
+ pMsg->TAG.pszTAG = pBuf;
+ }
}
memcpy(pBuf, pszBuf, pMsg->iLenTAG);
@@ -1695,24 +1699,7 @@ void MsgSetMSGoffs(msg_t *pMsg, short offs)
pMsg->iLenMSG = ustrlen(pMsg->pszRawMsg + offs);
pMsg->offMSG = offs;
}
-#if 0
-/* rgerhards 2004-11-09: set MSG in msg object
- */
-void MsgSetMSG(msg_t *pMsg, char* pszMSG)
-{
- assert(pMsg != NULL);
- assert(pszMSG != NULL);
- if(pMsg->pszMSG != NULL)
- free(pMsg->pszMSG);
-
- pMsg->iLenMSG = strlen(pszMSG);
- if((pMsg->pszMSG = (uchar*) malloc(pMsg->iLenMSG + 1)) != NULL)
- memcpy(pMsg->pszMSG, pszMSG, pMsg->iLenMSG + 1);
- else
- dbgprintf("MsgSetMSG could not allocate memory for pszMSG buffer.");
-}
-#endif
/* set raw message in message object. Size of message is provided.
* rgerhards, 2009-06-16
@@ -1869,6 +1856,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
int iLen;
short iOffs;
+ BEGINfunc
#ifdef FEATURE_REGEXP
/* Variables necessary for regular expression matching */
size_t nmatch = 10;
@@ -2562,6 +2550,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
*pPropLen = bufLen;
/*dbgprintf("MsgGetProp(\"%s\"): \"%s\"\n", pName, pRes); only for verbose debug logging */
+ ENDfunc
return(pRes);
}
diff --git a/runtime/msg.h b/runtime/msg.h
index 4cdb0762..ec18b29d 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -74,7 +74,6 @@ struct msg {
int iLenRawMsg; /* length of raw message */
short offAfterPRI; /* offset, at which raw message WITHOUT PRI part starts in pszRawMsg */
short offMSG; /* offset at which the MSG part starts in pszRawMsg */
- //uchar *pszMSG; /* the MSG part itself */
int iLenMSG; /* Length of the MSG part */
int iLenTAG; /* Length of the TAG part */
uchar *pszHOSTNAME; /* HOSTNAME from syslog message */
diff --git a/template.c b/template.c
index aacd4dbd..93d0539c 100644
--- a/template.c
+++ b/template.c
@@ -571,6 +571,7 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
cstrFinalize(pStrB);
if(cstrConvSzStrAndDestruct(pStrB, &pTpe->data.field.pPropRepl, 0) != RS_RET_OK)
return 1;
+// TODO: another optimization: map name to integer id OPT
/* Check frompos, if it has an R, then topos should be a regex */
if(*p == ':') {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dbaf85f0..0800f667 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,6 +42,7 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/1.parse1 \
testsuites/2.parse1 \
testsuites/3.parse1 \
+ testsuites/oversizeTag-1.parse1 \
testsuites/date1.parse1 \
testsuites/date2.parse1 \
testsuites/date3.parse1 \
diff --git a/tests/testsuites/oversizeTag-1.parse1 b/tests/testsuites/oversizeTag-1.parse1
new file mode 100644
index 00000000..56510c63
--- /dev/null
+++ b/tests/testsuites/oversizeTag-1.parse1
@@ -0,0 +1,3 @@
+<38>Mar 27 19:06:53 source_server 0123456780123456780123456780123456789: MSG part
+38,auth,info,Mar 27 19:06:53,source_server,0123456780123456780123456780123456789,0123456780123456780123456780123456789:, MSG part
+# yet another real-life sample where we had some issues with