Module: kamailio
Branch: 4.4
Commit: 3acfc0003915401f1a27120b9a5d329b2e52e78d
URL:
https://github.com/kamailio/kamailio/commit/3acfc0003915401f1a27120b9a5d329…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-05-27T11:52:27+02:00
uac: proper handling of empty attribute for uacreg refresh
- reg_db_set_attr() does a continue on empty value, but for this
operation was not used inside a loop
- reported by Dmitri Savolainen, GH #643
(cherry picked from commit a34b382002cf9efe13c913f547ffacec3bd7757f)
---
Modified: modules/uac/uac_reg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3acfc0003915401f1a27120b9a5d329…
Patch:
https://github.com/kamailio/kamailio/commit/3acfc0003915401f1a27120b9a5d329…
---
diff --git a/modules/uac/uac_reg.c b/modules/uac/uac_reg.c
index 8ff63bd..63b0ff0 100644
--- a/modules/uac/uac_reg.c
+++ b/modules/uac/uac_reg.c
@@ -1310,46 +1310,48 @@ int uac_reg_db_refresh(str *pl_uuid)
}
}
- memset(®, 0, sizeof(reg_uac_t));;
- i = 0;
- /* check for NULL values ?!?! */
- reg_db_set_attr(l_uuid, 0);
- reg_db_set_attr(l_username, 1);
- reg_db_set_attr(l_domain, 2);
- reg_db_set_attr(r_username, 3);
- reg_db_set_attr(r_domain, 4);
- /* realm may be empty */
- if(!VAL_NULL(&RES_ROWS(db_res)[i].values[5])) {
- reg.realm.s = (char*)(RES_ROWS(db_res)[i].values[5].val.string_val);
- reg.realm.len = strlen(reg.realm.s);
- }
- reg_db_set_attr(auth_username, 6);
- reg_db_set_attr(auth_password, 7);
- reg_db_set_attr(auth_proxy, 8);
- reg.expires = (unsigned int)RES_ROWS(db_res)[i].values[9].val.int_val;
- reg.h_uuid = reg_compute_hash(®.l_uuid);
- reg.h_user = reg_compute_hash(®.l_username);
- reg.flags = (unsigned int)RES_ROWS(db_res)[i].values[10].val.int_val;
- reg.reg_delay = (unsigned int)RES_ROWS(db_res)[i].values[11].val.int_val;
-
- lock_get(_reg_htable_gc_lock);
- if(reg_ht_get_byuuid(pl_uuid)!=NULL)
- {
- if(reg_ht_update_attrs(®)<0)
- {
- lock_release(_reg_htable_gc_lock);
- LM_ERR("Error updating reg to htable\n");
- goto error;
+ memset(®, 0, sizeof(reg_uac_t));
+ /* only one record - use FOR to catch 'contunue' on invalid set attr */
+ for(i=0; i<1; i++) {
+ /* check for NULL values ?!?! */
+ reg_db_set_attr(l_uuid, 0);
+ reg_db_set_attr(l_username, 1);
+ reg_db_set_attr(l_domain, 2);
+ reg_db_set_attr(r_username, 3);
+ reg_db_set_attr(r_domain, 4);
+ /* realm may be empty */
+ if(!VAL_NULL(&RES_ROWS(db_res)[i].values[5])) {
+ reg.realm.s = (char*)(RES_ROWS(db_res)[i].values[5].val.string_val);
+ reg.realm.len = strlen(reg.realm.s);
}
- } else {
- if(reg_ht_add(®)<0)
+ reg_db_set_attr(auth_username, 6);
+ reg_db_set_attr(auth_password, 7);
+ reg_db_set_attr(auth_proxy, 8);
+ reg.expires = (unsigned int)RES_ROWS(db_res)[i].values[9].val.int_val;
+ reg.h_uuid = reg_compute_hash(®.l_uuid);
+ reg.h_user = reg_compute_hash(®.l_username);
+ reg.flags = (unsigned int)RES_ROWS(db_res)[i].values[10].val.int_val;
+ reg.reg_delay = (unsigned int)RES_ROWS(db_res)[i].values[11].val.int_val;
+
+ lock_get(_reg_htable_gc_lock);
+ if(reg_ht_get_byuuid(pl_uuid)!=NULL)
{
- lock_release(_reg_htable_gc_lock);
- LM_ERR("Error adding reg to htable\n");
- goto error;
+ if(reg_ht_update_attrs(®)<0)
+ {
+ lock_release(_reg_htable_gc_lock);
+ LM_ERR("Error updating reg to htable\n");
+ goto error;
+ }
+ } else {
+ if(reg_ht_add(®)<0)
+ {
+ lock_release(_reg_htable_gc_lock);
+ LM_ERR("Error adding reg to htable\n");
+ goto error;
+ }
}
+ lock_release(_reg_htable_gc_lock);
}
- lock_release(_reg_htable_gc_lock);
reg_dbf.free_result(reg_db_con, db_res);
reg_dbf.close(reg_db_con);