imtcp segfaults under certain configuration.
Details are in the patches.

Tomas
>From 06508412afe6c496c611ba89c3ca77404d932832 Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Mon, 9 Dec 2013 17:59:46 +0100
Subject: [PATCH 1/2] bugfix: prevent a segfault during imtcp's shutdown

If imtcp is loaded and no listeners are configured (which is uncommon),
rsyslog crashes during shutdown.

The cause is that startWorkerPool() is called unconditionally during
modExit() even if there are no listerners. Correcting this triggers a
memleak of the wrkrMut mutex which shouldn't have been destroyed in
startWorkerPool() in the first place.
---
 tcpsrv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tcpsrv.c b/tcpsrv.c
index c64fa3e..9e01e13 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -1395,7 +1395,10 @@ stopWorkerPool(void)
 
 BEGINmodExit
 CODESTARTmodExit
-	stopWorkerPool();
+	if(bWrkrRunning) {
+		stopWorkerPool();
+		bWrkrRunning = 0;
+	}
 	/* de-init in reverse order! */
 	tcpsrvClassExit();
 	tcps_sessClassExit();
-- 
1.8.4.3

>From e6f03d234adc08d255990f27368d1cc342831bf6 Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Mon, 9 Dec 2013 18:11:48 +0100
Subject: [PATCH 2/2] bugfix: prevent a memleak in imtcp

This cleans up a memleak triggered by the previous commit
---
 tcpsrv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tcpsrv.c b/tcpsrv.c
index 9e01e13..50214d8 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -1386,8 +1386,6 @@ stopWorkerPool(void)
 		pthread_cond_destroy(&wrkrInfo[i].run);
 	}
 	pthread_cond_destroy(&wrkrIdle);
-	pthread_mutex_destroy(&wrkrMut);
-
 }
 
 
@@ -1402,6 +1400,7 @@ CODESTARTmodExit
 	/* de-init in reverse order! */
 	tcpsrvClassExit();
 	tcps_sessClassExit();
+	pthread_mutex_destroy(&wrkrMut);
 ENDmodExit
 
 
-- 
1.8.4.3

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to