Blame SOURCES/rsyslog-8.24.0-rhbz1422414-glbDoneLoadCnf-segfault.patch

a856a8
From d649d77cd585f70c6122d7e4ce95e82ad0e9af5e Mon Sep 17 00:00:00 2001
a856a8
From: Radovan Sroka <rsroka@redhat.com>
a856a8
Date: Thu, 23 Feb 2017 15:05:27 +0100
a856a8
Subject: [PATCH] Fixed segfault in glblDoneLoadCnf()
a856a8
a856a8
This is caused by uninitialized net static structure in glbl objUse(net)
a856a8
is not called after start of glbl module.
a856a8
a856a8
It looks like it is not possible to use objUse(net) when glbl module
a856a8
starts. So we call it inside of glblDoneLoadCnf().
a856a8
---
a856a8
 runtime/glbl.c   | 6 ++++--
a856a8
 runtime/glbl.h   | 2 +-
a856a8
 runtime/rsconf.c | 6 +++---
a856a8
 3 files changed, 8 insertions(+), 6 deletions(-)
a856a8
a856a8
diff --git a/runtime/glbl.c b/runtime/glbl.c
a856a8
index 2079c46..1a32c2d 100644
a856a8
--- a/runtime/glbl.c
a856a8
+++ b/runtime/glbl.c
a856a8
@@ -1076,11 +1076,13 @@ do_setenv(const char *const var)
a856a8
 /* This processes the "regular" parameters which are to be set after the
a856a8
  * config has been fully loaded.
a856a8
  */
a856a8
-void
a856a8
+rsRetVal
a856a8
 glblDoneLoadCnf(void)
a856a8
 {
a856a8
 	int i;
a856a8
 	unsigned char *cstr;
a856a8
+	DEFiRet;
a856a8
+	CHKiRet(objUse(net, CORE_COMPONENT));
a856a8
 
a856a8
 	qsort(tzinfos, ntzinfos, sizeof(tzinfo_t), qs_arrcmp_tzinfo);
a856a8
 	DBGPRINTF("Timezone information table (%d entries):\n", ntzinfos);
a856a8
@@ -1210,7 +1212,7 @@ glblDoneLoadCnf(void)
a856a8
 		stddbg = -1;
a856a8
 	}
a856a8
 
a856a8
-finalize_it:	return;
a856a8
+finalize_it:	RETiRet;
a856a8
 }
a856a8
 
a856a8
 
a856a8
diff --git a/runtime/glbl.h b/runtime/glbl.h
a856a8
index 6d18a2c..048c0a6 100644
a856a8
--- a/runtime/glbl.h
a856a8
+++ b/runtime/glbl.h
a856a8
@@ -125,7 +125,7 @@ void glblProcessCnf(struct cnfobj *o);
a856a8
 void glblProcessTimezone(struct cnfobj *o);
a856a8
 void glblProcessMainQCnf(struct cnfobj *o);
a856a8
 void glblDestructMainqCnfObj(void);
a856a8
-void glblDoneLoadCnf(void);
a856a8
+rsRetVal glblDoneLoadCnf(void);
a856a8
 const uchar * glblGetWorkDirRaw(void);
a856a8
 tzinfo_t* glblFindTimezoneInfo(char *id);
a856a8
 int GetGnuTLSLoglevel(void);
a856a8
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
a856a8
index dc6bd7f..f337e1f 100644
a856a8
--- a/runtime/rsconf.c
a856a8
+++ b/runtime/rsconf.c
a856a8
@@ -627,11 +627,11 @@ dropPrivileges(rsconf_t *cnf)
a856a8
 /* tell the rsysog core (including ourselfs) that the config load is done and
a856a8
  * we need to prepare to move over to activate mode.
a856a8
  */
a856a8
-static inline void
a856a8
+static inline rsRetVal
a856a8
 tellCoreConfigLoadDone(void)
a856a8
 {
a856a8
 	DBGPRINTF("telling rsyslog core that config load for %p is done\n", loadConf);
a856a8
-	glblDoneLoadCnf();
a856a8
+	return glblDoneLoadCnf();
a856a8
 }
a856a8
 
a856a8
 
a856a8
@@ -1345,7 +1345,7 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
a856a8
 	DBGPRINTF("Number of actions in this configuration: %d\n", iActionNbr);
a856a8
 	rulesetOptimizeAll(loadConf);
a856a8
 
a856a8
-	tellCoreConfigLoadDone();
a856a8
+	CHKiRet(tellCoreConfigLoadDone());
a856a8
 	tellModulesConfigLoadDone();
a856a8
 
a856a8
 	tellModulesCheckConfig();