Przeglądaj źródła

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.
Charles Chance 10 lat temu
rodzic
commit
feaed39802
1 zmienionych plików z 10 dodań i 3 usunięć
  1. 10 3
      modules/dmq_usrloc/usrloc_sync.c

+ 10 - 3
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) {