summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-24 05:59:06 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-24 05:59:06 +0000
commitfe0da1ef850dc9e93993f8332a87cbf815cea2f7 (patch)
tree72c2bb4fa917493af3b1e91b725d15009376dcb4
parent9ee5888309e1f39f52546deaea4bcd3bdc216d8d (diff)
downloadrsyslog-fe0da1ef850dc9e93993f8332a87cbf815cea2f7.tar.gz
rsyslog-fe0da1ef850dc9e93993f8332a87cbf815cea2f7.tar.xz
rsyslog-fe0da1ef850dc9e93993f8332a87cbf815cea2f7.zip
fixed a small memory leak when HUPing syslogd. The allowed sender list now
gets freed. thanks varmojfekoj to for the patch.
-rw-r--r--ChangeLog2
-rw-r--r--syslogd.c33
2 files changed, 35 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 649f69fb..6b719d44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@ Version 1.17.3 (rgerhards), 2007-07-2?
- rsyslogd now checks on startup if it is capable to performa any work
at all. If it cant, it complains and terminates
thanks to Michel Samia for providing the patch!
+- fixed a small memory leak when HUPing syslogd. The allowed sender
+ list now gets freed. thanks varmojfekoj to for the patch.
---------------------------------------------------------------------------
Version 1.17.2 (rgerhards), 2007-07-23
- made the port part of the -r option optional. Needed for backward
diff --git a/syslogd.c b/syslogd.c
index 8dca5d28..c745b7ab 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -745,6 +745,24 @@ static rsRetVal AddAllowedSenderEntry(struct AllowedSenders **ppRoot, struct All
return RS_RET_OK;
}
+/* function to clear the allowed sender structure in cases where
+ * it must be freed (occurs most often when HUPed.
+ * TODO: reconsider recursive implementation
+ */
+static void clearAllowedSenders (struct AllowedSenders *pAllow) {
+ if (pAllow != NULL) {
+ if (pAllow->pNext != NULL)
+ clearAllowedSenders (pAllow->pNext);
+ else {
+ if (F_ISSET(pAllow->allowedSender.flags, ADDR_NAME))
+ free (pAllow->allowedSender.addr.HostWildcard);
+ else
+ free (pAllow->allowedSender.addr.NetAddr);
+
+ free (pAllow);
+ }
+ }
+}
/* function to add an allowed sender to the allowed sender list. The
* root of the list is caller-provided, so it can be used for all
@@ -4133,6 +4151,21 @@ static void init()
pDfltProgNameCmp = NULL;
eDfltHostnameCmpMode = HN_NO_COMP;
+ if (restart) {
+ if (pAllowedSenders_UDP != NULL) {
+ clearAllowedSenders (pAllowedSenders_UDP);
+ pAllowedSenders_UDP = NULL;
+ }
+
+ if (pAllowedSenders_TCP != NULL) {
+ clearAllowedSenders (pAllowedSenders_TCP);
+ pAllowedSenders_TCP = NULL;
+ }
+ }
+
+ assert (pAllowedSenders_UDP == NULL &&
+ pAllowedSenders_TCP == NULL );
+
nextp = NULL;
/* I was told by an IPv6 expert that calling getservbyname() seems to be
* still valid, at least for the use case we have. So I re-enabled that