Module: kamailio
Branch: 4.1
Commit: eeee655ee6eb1698aef2f788a271d68a663bde73
URL: 
https://github.com/kamailio/kamailio/commit/eeee655ee6eb1698aef2f788a271d68a663bde73

Author: smititelu <[email protected]>
Committer: Stefan Mititelu <[email protected]>
Date: 2015-12-16T16:01:36+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/eeee655ee6eb1698aef2f788a271d68a663bde73.diff
Patch: 
https://github.com/kamailio/kamailio/commit/eeee655ee6eb1698aef2f788a271d68a663bde73.patch

---

diff --git a/modules/debugger/debugger_api.c b/modules/debugger/debugger_api.c
index 39e599b..90ba11f 100644
--- a/modules/debugger/debugger_api.c
+++ b/modules/debugger/debugger_api.c
@@ -1188,6 +1188,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 2f0caa7..3d162bb 100644
--- a/modules/debugger/debugger_mod.c
+++ b/modules/debugger/debugger_mod.c
@@ -139,6 +139,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));
@@ -188,6 +194,7 @@ static int child_init(int rank)
  */
 static void mod_destroy(void)
 {
+       dbg_cfg = NULL;
 }
 
 /**
@@ -309,20 +316,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;
 
 }
-


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to