From f94cd60dac39fdedbf058b2c97dbf535e54faecf Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 28 Mar 2008 14:18:40 +0000 Subject: - bugfix: regular expressions inside property replacer did not work properly --- msg.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'msg.c') diff --git a/msg.c b/msg.c index 0875cd50..0dd8f416 100644 --- a/msg.c +++ b/msg.c @@ -1572,8 +1572,8 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, #ifdef FEATURE_REGEXP /* Variables necessary for regular expression matching */ - size_t nmatch = 2; - regmatch_t pmatch[2]; + size_t nmatch = 1; + regmatch_t pmatch[1]; #endif assert(pMsg != NULL); @@ -1807,8 +1807,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, dbgprintf("debug: String to match for regex is: %s\n", pRes); if(objUse(regexp, LM_REGEXP_FILENAME) == RS_RET_OK) { - if (0 != regexp.regexec(&pTpe->data.field.re, pRes, nmatch, - pmatch, 0)) { + if (0 != regexp.regexec(&pTpe->data.field.re, pRes, nmatch, pmatch, 0)) { /* we got no match! */ if (*pbMustBeFreed == 1) { free(pRes); @@ -1821,7 +1820,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, int iLenBuf; char *pB; - iLenBuf = pmatch[1].rm_eo - pmatch[1].rm_so; + iLenBuf = pmatch[0].rm_eo - pmatch[0].rm_so; pB = (char *) malloc((iLenBuf + 1) * sizeof(char)); if (pB == NULL) { @@ -1832,7 +1831,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, } /* Lets copy the matched substring to the buffer */ - memcpy(pB, pRes + pmatch[1].rm_so, iLenBuf); + memcpy(pB, pRes + pmatch[0].rm_so, iLenBuf); pB[iLenBuf] = '\0';/* terminate string, did not happen before */ if (*pbMustBeFreed == 1) -- cgit v1.2.3