Module: kamailio Branch: master Commit: 0954a069ac92c70e190875fdc05150a7d2004ddb URL: https://github.com/kamailio/kamailio/commit/0954a069ac92c70e190875fdc05150a7...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-09-17T10:11:03+02:00
usrloc: test first if all params are retrieved for rpc ul.add
- avoid logging unset values
---
Modified: src/modules/usrloc/ul_rpc.c
---
Diff: https://github.com/kamailio/kamailio/commit/0954a069ac92c70e190875fdc05150a7... Patch: https://github.com/kamailio/kamailio/commit/0954a069ac92c70e190875fdc05150a7...
---
diff --git a/src/modules/usrloc/ul_rpc.c b/src/modules/usrloc/ul_rpc.c index c27921d0fc..f679ef5cff 100644 --- a/src/modules/usrloc/ul_rpc.c +++ b/src/modules/usrloc/ul_rpc.c @@ -579,19 +579,21 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
ret = rpc->scan(ctx, "SSSdfSddd", &table, &aor, &contact, &ci.expires, &dtemp, &path, &ci.flags, &ci.cflags, &ci.methods); + if ( ret != 9) { + rpc->fault(ctx, 500, "Not enough parameters or wrong format"); + return; + } if(path.len==1 && (strncmp(path.s, "0", 1)==0)) { LM_DBG("path == 0 -> unset\n"); - } - else { + } else { ci.path = &path; } - LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n", + LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d" + " dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n", ret, table.len, table.s, aor.len, aor.s, contact.len, contact.s, - (int) ci.expires, dtemp, (ci.path)?ci.path->len:0, (ci.path && ci.path->s)?ci.path->s:"", ci.flags, ci.cflags, (int) ci.methods); - if ( ret != 9) { - rpc->fault(ctx, 500, "Not enough parameters or wrong format"); - return; - } + (int) ci.expires, dtemp, (ci.path)?ci.path->len:0, + (ci.path && ci.path->s)?ci.path->s:"", ci.flags, ci.cflags, + (int) ci.methods); ci.q = double2q(dtemp); temp.s = q2str(ci.q, (unsigned int*)&temp.len); LM_DBG("q:%.*s\n", temp.len, temp.s); @@ -627,7 +629,8 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx) } c = 0; } else { - if (get_ucontact( r, &contact, &rpc_ul_cid, &rpc_ul_path, RPC_UL_CSEQ+1, &c) < 0) + if (get_ucontact( r, &contact, &rpc_ul_cid, &rpc_ul_path, + RPC_UL_CSEQ+1, &c) < 0) { unlock_udomain( dom, &aor); rpc->fault(ctx, 500, "Can't get record");