Module: kamailio
Branch: 4.3
Commit: a562275acacb2bd98b075f3132ddbce8de456f41
URL:
https://github.com/kamailio/kamailio/commit/a562275acacb2bd98b075f3132ddbce…
Author: smititelu <stefan.mititelu(a)1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu(a)1and1.ro>
Date: 2015-12-16T15:53:26+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/a562275acacb2bd98b075f3132ddbce…
Patch:
https://github.com/kamailio/kamailio/commit/a562275acacb2bd98b075f3132ddbce…
---
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..468b882 100644
--- a/modules/debugger/debugger_mod.c
+++ b/modules/debugger/debugger_mod.c
@@ -141,10 +141,16 @@ static int mod_init(void)
LM_ERR("Fail to declare the configuration\n");
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));
+ /* anyhow, should fail before */
+ if (!dbg_cfg) {
+ return -1;
+ }
+
if(dbg_init_mod_levels(cfg_get(dbg, dbg_cfg, mod_hash_size))<0)
{
LM_ERR("failed to init per module log level\n");
@@ -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;
}
-