From d471e71adabdad4fba8b59c4017a1c5f1f111073 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 7 Mar 2008 16:34:51 +0000 Subject: fixed potential infinite loop condition when module load failed on startup --- Makefile.am | 10 +++++----- doc/rsyslog_conf.html | 8 ++++++-- msg.c | 2 +- obj.c | 9 +++++---- stringbuf.c | 2 +- template.c | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1fc48c18..c924f7bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -123,11 +123,11 @@ endif # regular expression support # if ENABLE_REGEXP -pkglib_LTLIBRARIES += regexp.la -regexp_la_SOURCES = regexp.c regexp.h -regexp_la_CPPFLAGS = $(pthreads_cflags) -regexp_la_LDFLAGS = -module -avoid-version -regexp_la_LIBADD = +pkglib_LTLIBRARIES += lmregexp.la +lmregexp_la_SOURCES = regexp.c regexp.h +lmregexp_la_CPPFLAGS = $(pthreads_cflags) +lmregexp_la_LDFLAGS = -module -avoid-version +lmregexp_la_LIBADD = endif # diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html index 11f80a2d..03b15c17 100644 --- a/doc/rsyslog_conf.html +++ b/doc/rsyslog_conf.html @@ -505,7 +505,7 @@ once they are implemented, it can make very much sense regex -Compares the property against the provided regular +Compares the property against the provided POSIX regular expression. @@ -547,7 +547,11 @@ code), this can be done easily by:

This filter will match when the message contains the string "ID-4711". Please note that the comparison is case-sensitive, so it would not match if "id-4711" would be contained in the message.

-

Getting property-based filters right can sometimes be +

:msg, regex, "fatal .* error"

+

This filter uses a POSIX regular expression. It matches when the +string contains the words "fatal" and "error" with anything in between +(e.g. "fatal net error" and "fatal lib error" but not "fatal error" as +two spaces are required by the regular expression!).

Getting property-based filters right can sometimes be challenging. In order to help you do it with as minimal effort as possible, rsyslogd spits out debug information for all property-based filters during their evaluation. To enable this, run rsyslogd in diff --git a/msg.c b/msg.c index 1076feae..d40087ad 100644 --- a/msg.c +++ b/msg.c @@ -1771,7 +1771,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, dbgprintf("debug: String to match for regex is: %s\n", pRes); - if(objUse(regexp, "regexp") == RS_RET_OK) { + if(objUse(regexp, "lmregexp") == RS_RET_OK) { if (0 != regexp.regexec(&pTpe->data.field.re, pRes, nmatch, pmatch, 0)) { /* we got no match! */ diff --git a/obj.c b/obj.c index 5a144727..910afe89 100644 --- a/obj.c +++ b/obj.c @@ -1058,8 +1058,6 @@ UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf) cstr_t *pStr = NULL; objInfo_t *pObjInfo; - CHKiRet(rsCStrConstructFromszStr(&pStr, pObjName)); - iRet = FindObjInfo(pStr, &pObjInfo); dbgprintf("source file %s requests object '%s', ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded); @@ -1077,13 +1075,15 @@ UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf) * looks like a good solution. -- rgerhards, 2008-03-07 */ pIf->ifIsLoaded = 2; + + CHKiRet(rsCStrConstructFromszStr(&pStr, pObjName)); + iRet = FindObjInfo(pStr, &pObjInfo); if(iRet == RS_RET_NOT_FOUND) { /* in this case, we need to see if we can dynamically load the object */ if(pObjFile == NULL) { FINALIZE; /* no chance, we have lost... */ } else { CHKiRet(module.Load(pObjFile)); - pIf->ifIsLoaded = 1; /* all went well! */ /* NOW, we must find it or we have a problem... */ CHKiRet(FindObjInfo(pStr, &pObjInfo)); } @@ -1091,7 +1091,8 @@ UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf) FINALIZE; /* give up */ } - pObjInfo->QueryIF(pIf); + CHKiRet(pObjInfo->QueryIF(pIf)); + pIf->ifIsLoaded = 1; /* we are happy */ finalize_it: if(pStr != NULL) diff --git a/stringbuf.c b/stringbuf.c index d5b77d99..8745c291 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -709,7 +709,7 @@ int rsCStrSzStrMatchRegex(cstr_t *pCS1, uchar *psz) BEGINfunc - if(objUse(regexp, "regexp") == RS_RET_OK) { + if(objUse(regexp, "lmregexp") == RS_RET_OK) { regexp.regcomp(&preq, (char*) rsCStrGetSzStr(pCS1), 0); ret = regexp.regexec(&preq, (char*) psz, 0, NULL, 0); regexp.regfree(&preq); diff --git a/template.c b/template.c index 5d13fd08..67be4140 100644 --- a/template.c +++ b/template.c @@ -627,7 +627,7 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl) /* Now i compile the regex */ /* Remember that the re is an attribute of the Template entry */ - if((iRetLocal = objUse(regexp, "regexp")) == RS_RET_OK) { + if((iRetLocal = objUse(regexp, "lmregexp")) == RS_RET_OK) { if(regexp.regcomp(&(pTpe->data.field.re), (char*) regex_char, 0) != 0) { dbgprintf("error: can not compile regex: '%s'\n", regex_char); pTpe->data.field.has_regex = 2; -- cgit