From f574400bb5d18306f3929170d5f4c165ea2b24f9 Mon Sep 17 00:00:00 2001
From: Rainer Gerhards
Date: Fri, 28 Mar 2008 13:39:32 +0000
Subject: bugfix: fixed small memory leak in template regular expressions
---
ChangeLog | 6 ++++--
doc/manual.html | 50 +++++++++++++++++++++++---------------------------
template.c | 28 ++++++++++++++++++++++++----
3 files changed, 51 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9c9f4fb0..dbc86b2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,5 @@
---------------------------------------------------------------------------
-Version 3.12.5 (rgerhards), 2008-03-??
+Version 3.12.5 (rgerhards), 2008-03-28
- bugfix: QHOUR and HHOUR properties were wrongly calculated
- bugfix: fixed memory leaks in stream class and imfile
- bugfix: $ModDir did invalid bounds checking, potential overlow in
@@ -12,7 +12,7 @@ Version 3.12.5 (rgerhards), 2008-03-??
- automatically generated compatibility config lines are now also
logged so that a user can diagnose problems with them
- added compatibility mode for -a, -o and -p options
-- MILESTONE: compatibility mode processing finished
+- compatibility mode processing finished
- changed default file output format to include high-precision timestamps
- added a buid-in template for previous syslogd file format
- added new $ActionFileDefaultTemplate directive
@@ -21,6 +21,8 @@ Version 3.12.5 (rgerhards), 2008-03-??
- added new $ActionForwardDefaultTemplate directive
- added new $ActionGSSForwardDefaultTemplate directive
- added build-in templates for easier configuration
+- bugfix: fixed small memory leak in tcpclt.c
+- bugfix: fixed small memory leak in template regular expressions
---------------------------------------------------------------------------
Version 3.12.4 (rgerhards), 2008-03-25
- Greatly enhanced rsyslogd's file write performance by disabling
diff --git a/doc/manual.html b/doc/manual.html
index 46bfd958..135d2fa0 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -1,5 +1,7 @@
-rsyslog documentation
+rsyslog documentation
+
+
RSyslog - Documentation
Rsyslog
@@ -7,12 +9,15 @@ is an enhanced syslogd
supporting, among others, MySQL,
PostgreSQL, failover
log destinations, syslog/tcp, fine grain output format
-control, and the ability to filter on any message part.
+control, high precision timestamps, queued operations and the ability to filter on any message
+part.
It is quite compatible to stock sysklogd and can be used as a drop-in
replacement. Its
advanced features make it suitable for enterprise-class, encryption protected syslog
relay chains while at the same time being very easy to setup for the
-novice user. And as we know what enterprise users really need, there is also professional rsyslog support available directly from the source!
+novice user. And as we know what enterprise users really need, there is
+also professional
+rsyslog support available directly from the source!
Visit the rsyslog
status page to obtain current
version information and ports. If you like rsyslog, you might
@@ -20,23 +25,13 @@ want to lend us a helping hand. It doesn't require a lot of
time - even a single mouse click helps. Learn how to help the rsyslog project.
Due to popular demand, there is now a side-by-side comparison
between rsyslog and syslog-ng.
-Warning: rsyslog
-v3 is under active development and as of this writing has a number of
-backwards compatibility issues. If you currently use v2,
-be
-sure to read the rsyslog v3 compatibility document!
-This also applies if you upgrade from stock sysklogd - you need to make
-some configuration file changes.
-Documentation for 3.x is currently sparse. If you need assistance,
-please post
-in the rsyslog forums!
-If you do not like this,
-use a stable
-branch release!
-Follow the links below for the
-
-- rsyslogd man page
-(somewhat outdated)
+If you are upgrading from rsyslog v2 or stock sysklogd,
+be
+sure to read the rsyslog v3 compatibility document! It will work even
+if you do not read the doc, but doing so will definitely improve your experience.
+Follow
+the links below for the
We have some in-depth papers on
@@ -86,16 +82,16 @@ to use the doc that came with it.
You can also browse the following online resources:
And don't forget about the rsyslog
diff --git a/template.c b/template.c
index 1d0526d6..75c9ce78 100644
--- a/template.c
+++ b/template.c
@@ -612,9 +612,8 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
longitud = regex_end - p;
/* Malloc for the regex string */
regex_char = (unsigned char *) malloc(longitud + 1);
- if (regex_char == NULL) {
- dbgprintf
- ("Could not allocate memory for template parameter!\n");
+ if(regex_char == NULL) {
+ dbgprintf("Could not allocate memory for template parameter!\n");
pTpe->data.field.has_regex = 0;
return 1;
/* TODO: RGer: check if we can recover better... (probably not) */
@@ -629,6 +628,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, LM_REGEXP_FILENAME)) == RS_RET_OK) {
+dbgprintf("compile data.field.re ptr: %p (pTpe %p)\n", (&(pTpe->data.field.re)), pTpe);
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;
@@ -849,6 +849,8 @@ void tplDeleteAll(void)
{
struct template *pTpl, *pTplDel;
struct templateEntry *pTpe, *pTpeDel;
+ rsRetVal iRetLocal;
+ BEGINfunc
pTpl = tplRoot;
while(pTpl != NULL) {
@@ -868,6 +870,12 @@ void tplDeleteAll(void)
free(pTpeDel->data.constant.pConstant);
break;
case FIELD:
+ /* check if we have a regexp and, if so, delete it */
+ if(pTpeDel->data.field.has_regex != 0) {
+ if((iRetLocal = objUse(regexp, LM_REGEXP_FILENAME)) == RS_RET_OK) {
+ regexp.regfree(&(pTpeDel->data.field.re));
+ }
+ }
/*dbgprintf("(FIELD), value: '%s'", pTpeDel->data.field.pPropRepl);*/
free(pTpeDel->data.field.pPropRepl);
break;
@@ -881,15 +889,20 @@ void tplDeleteAll(void)
free(pTplDel->pszName);
free(pTplDel);
}
+ ENDfunc
}
+
/* Destroy all templates obtained from conf file
- * preserving hadcoded ones. This is called from init().
+ * preserving hardcoded ones. This is called from init().
*/
void tplDeleteNew(void)
{
struct template *pTpl, *pTplDel;
struct templateEntry *pTpe, *pTpeDel;
+ rsRetVal iRetLocal;
+
+ BEGINfunc
if(tplRoot == NULL || tplLastStatic == NULL)
return;
@@ -914,6 +927,12 @@ void tplDeleteNew(void)
free(pTpeDel->data.constant.pConstant);
break;
case FIELD:
+ /* check if we have a regexp and, if so, delete it */
+ if(pTpeDel->data.field.has_regex != 0) {
+ if((iRetLocal = objUse(regexp, LM_REGEXP_FILENAME)) == RS_RET_OK) {
+ regexp.regfree(&(pTpeDel->data.field.re));
+ }
+ }
/*dbgprintf("(FIELD), value: '%s'", pTpeDel->data.field.pPropRepl);*/
free(pTpeDel->data.field.pPropRepl);
break;
@@ -927,6 +946,7 @@ void tplDeleteNew(void)
free(pTplDel->pszName);
free(pTplDel);
}
+ ENDfunc
}
/* Store the pointer to the last hardcoded teplate */
--
cgit