Module: sip-router Branch: carstenbock/ims Commit: 2dd022147ee1dee2c30bf0854325d87993205419 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2dd02214...
Author: Carsten Bock carsten@bock.info Committer: Carsten Bock carsten@bock.info Date: Tue Mar 29 11:23:45 2011 +0200
- several security checks and bug-fixes
---
modules_k/registrar/lookup.c | 13 +++++++++++-- modules_k/registrar/save.c | 13 ++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/modules_k/registrar/lookup.c b/modules_k/registrar/lookup.c index 535cbd8..4743b9d 100644 --- a/modules_k/registrar/lookup.c +++ b/modules_k/registrar/lookup.c @@ -87,6 +87,8 @@ static int restore_reg_avps(ucontact_t* c) avp_name_t name; str *s; + LM_DBG("Restoring AVP's: %p / %p\n", c, c->avps); + /* remove all these AVPs ? */ avp = c->avps; while (avp) { @@ -97,6 +99,7 @@ static int restore_reg_avps(ucontact_t* c) /* add stored AVPs */ avp = c->avps; while (avp) { + LM_DBG("avp %p\n", avp); get_avp_val(avp, &val); if (avp->flags & AVP_NAME_STR) { s = get_avp_name(avp); @@ -105,8 +108,14 @@ static int restore_reg_avps(ucontact_t* c) name.s.s = NULL; name.s.len = 0; } - } else name.n = avp->id; - + LM_DBG("AVP s:%.*s\n", name.s.len, name.s.s); + } else { + name.n = avp->id; + LM_DBG("AVP i:%d\n", name.n); + } + if ((val.s.s) && (val.s.len > 0)) + LM_DBG("Val s:%.*s\n", val.s.len, val.s.s); + LM_DBG("Val i:%d\n", val.n); /* modify flags here? */ add_avp(avp->flags, name, val); diff --git a/modules_k/registrar/save.c b/modules_k/registrar/save.c index 6fcde7c..4fe0df7 100644 --- a/modules_k/registrar/save.c +++ b/modules_k/registrar/save.c @@ -110,6 +110,7 @@ static inline avp_t *avp_dup(avp_t *avp) */ static void remove_avp_contact(struct ucontact *c) { avp_t *n; + while (c->avps) { n = c->avps->next; shm_free(c->avps); @@ -131,7 +132,7 @@ static int create_avp_list(avp_t * avp_list) { n = reg_avp_list; while (n) { /* Search for the AVP */ - avp = search_first_avp(avp->flags, n->name, 0, &ss); + avp = search_first_avp(n->type, n->name, 0, &ss); while(avp) { dup = avp_dup(avp); if (dup) { @@ -165,10 +166,12 @@ static int new_reg_avps(ucontact_info_t* c) */ static int update_reg_avps(struct ucontact *c) { - /* Remove existing AVP's from this contact: */ - remove_avp_contact(c); - - return create_avp_list(c->avps); + if (c) { + /* Remove existing AVP's from this contact: */ + remove_avp_contact(c); + return create_avp_list(c->avps); + } + return -1; }
/*! \brief