Module: kamailio
Branch: 4.3
Commit: feaed39802a86b1701f3db4aff0e64bed9d1cd04
URL: 
https://github.com/kamailio/kamailio/commit/feaed39802a86b1701f3db4aff0e64bed9d1cd04

Author: Charles Chance <charles.cha...@sipcentric.com>
Committer: Charles Chance <charles.cha...@sipcentric.com>
Date: 2015-09-07T13:02:02+01:00

dmq_usrloc: check existence of usrloc domain before continuing.

- avoids crash caused by passing null pointer to get_urecord_by_ruid().
- eventually need to implement multi-domain replication but usrloc API needs 
enhancing first.

---

Modified: modules/dmq_usrloc/usrloc_sync.c

---

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

---

diff --git a/modules/dmq_usrloc/usrloc_sync.c b/modules/dmq_usrloc/usrloc_sync.c
index 3bd0c24..f5ef20f 100644
--- a/modules/dmq_usrloc/usrloc_sync.c
+++ b/modules/dmq_usrloc/usrloc_sync.c
@@ -51,7 +51,10 @@ static int add_contact(str aor, ucontact_info_t* ci)
        str contact;
        int res;
 
-       dmq_ul.get_udomain("location", &_d);
+        if (dmq_ul.get_udomain("location", &_d) < 0) {
+                LM_ERR("Failed to get domain\n");
+                return -1;
+        }
        res = dmq_ul.get_urecord(_d, &aor, &r);
        if (res < 0) {
                LM_ERR("failed to retrieve record from usrloc\n");
@@ -116,6 +119,12 @@ void usrloc_get_all_ucontact(dmq_node_t* node)
     LM_ERR("dmq_ul.get_all_ucontacts is NULL\n");
     goto done;
   }
+
+       if (dmq_ul.get_udomain("location", &_d) < 0) {
+               LM_ERR("Failed to get domain\n");
+               goto done;
+       }
+
        rval = dmq_ul.get_all_ucontacts(buf, len, 0, 0, 1);
        if (rval<0) {
                LM_ERR("failed to fetch contacts\n");
@@ -161,8 +170,6 @@ void usrloc_get_all_ucontact(dmq_node_t* node)
         memcpy( &aorhash, cp, sizeof(aorhash));
         cp = (char*)cp + sizeof(aorhash);
 
-        dmq_ul.get_udomain("location", &_d);
-
         res = dmq_ul.get_urecord_by_ruid(_d, aorhash, &ruid, &r, &ptr);
         aor = r->aor;
         if (res > 0) {


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to