[sr-dev] git:4.2:43d01aab: debugger: Fix coredump when kamailio stopped

Stefan Mititelu stefan.mititelu at 1and1.ro
Wed Dec 16 14:58:31 CET 2015


Module: kamailio
Branch: 4.2
Commit: 43d01aab8b0dd4d6bdfa25e22a399ed81b468db1
URL: https://github.com/kamailio/kamailio/commit/43d01aab8b0dd4d6bdfa25e22a399ed81b468db1

Author: smititelu <stefan.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Date: 2015-12-16T15:58:11+02:00

debugger: Fix coredump when kamailio stopped

Upon kamailio stop, 'dbg_cfg' pointed to invalid memory zone(not NULL).
Reset the pointer to NULL upon module_destroy() and do the NULL checks.

Reported by foucse in issue #446.

(cherry picked from commit 64583809c677384e2fcd54a5ba7f921b3ea59c51)

---

Modified: modules/debugger/debugger_api.c
Modified: modules/debugger/debugger_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/43d01aab8b0dd4d6bdfa25e22a399ed81b468db1.diff
Patch: https://github.com/kamailio/kamailio/commit/43d01aab8b0dd4d6bdfa25e22a399ed81b468db1.patch

---

diff --git a/modules/debugger/debugger_api.c b/modules/debugger/debugger_api.c
index 05f904e..0f5f65d 100644
--- a/modules/debugger/debugger_api.c
+++ b/modules/debugger/debugger_api.c
@@ -1221,6 +1221,10 @@ int dbg_get_mod_debug_level(char *mname, int mnlen, int *mlevel)
 	if(_dbg_mod_table==NULL)
 		return -1;
 
+	if (!dbg_cfg) {
+		return -1;
+	}
+
 	if(cfg_get(dbg, dbg_cfg, mod_level_mode)==0)
 		return -1;
 
diff --git a/modules/debugger/debugger_mod.c b/modules/debugger/debugger_mod.c
index 496492f..0803dcc 100644
--- a/modules/debugger/debugger_mod.c
+++ b/modules/debugger/debugger_mod.c
@@ -141,6 +141,12 @@ static int mod_init(void)
 		LM_ERR("Fail to declare the configuration\n");
 		return -1;
 	}
+
+	/* anyhow, should fail before */
+	if (!dbg_cfg) {
+                return -1;
+	}
+
 	LM_DBG("cfg level_mode:%d hash_size:%d\n",
 		cfg_get(dbg, dbg_cfg, mod_level_mode),
 		cfg_get(dbg, dbg_cfg, mod_hash_size));
@@ -190,6 +196,7 @@ static int child_init(int rank)
  */
 static void mod_destroy(void)
 {
+	dbg_cfg = NULL;
 }
 
 /**
@@ -311,20 +318,27 @@ static int dbg_mod_level_param(modparam_t type, void *val)
 	}
 	s.s = (char*)val;
 	s.len = p - s.s;
+
+	if (!dbg_cfg) {
+                return -1;
+	}
+
 	LM_DBG("cfg level_mode:%d hash_size:%d\n",
 		cfg_get(dbg, dbg_cfg, mod_level_mode),
 		cfg_get(dbg, dbg_cfg, mod_hash_size));
+
 	if(dbg_init_mod_levels(cfg_get(dbg, dbg_cfg, mod_hash_size))<0)
 	{
 		LM_ERR("failed to init per module log level\n");
 		return -1;
 	}
+
 	if(dbg_set_mod_debug_level(s.s, s.len, &l)<0)
 	{
 		LM_ERR("cannot store parameter: %s\n", (char*)val);
 		return -1;
 	}
+
 	return 0;
 
 }
-




More information about the sr-dev mailing list