Module: kamailio
Branch: master
Commit: 41714a49e88800378db37670fbc22cafb7eca81a
URL:
https://github.com/kamailio/kamailio/commit/41714a49e88800378db37670fbc22ca…
Author: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2020-05-29T08:41:44+02:00
dispatcher: rework attrs parameter in rpc 'add' command
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatcher.c
---
Diff:
https://github.com/kamailio/kamailio/commit/41714a49e88800378db37670fbc22ca…
Patch:
https://github.com/kamailio/kamailio/commit/41714a49e88800378db37670fbc22ca…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 8cff6cdb56..d859dc3907 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2426,10 +2426,6 @@ int ds_add_dst(int group, str *address, int flags, str *attrs)
setn = _ds_list_nr;
priority = 0;
- if (attrs->len == 0) {
- attrs->s = 0;
- }
-
*next_idx = (*crt_idx + 1) % 2;
ds_avl_destroy(&ds_lists[*next_idx]);
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index b2693a2947..836038442f 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -1798,15 +1798,19 @@ static const char *dispatcher_rpc_add_doc[2] = {
*/
static void dispatcher_rpc_add(rpc_t *rpc, void *ctx)
{
- int group, flags;
+ int group, flags, nparams;
str dest;
- str attrs;
+ str attrs;
flags = 0;
- if(rpc->scan(ctx, "dS*d", &group, &dest, &flags, &attrs)
< 3) {
+ nparams = rpc->scan(ctx, "dS*dS", &group, &dest, &flags,
&attrs);
+ if(nparams < 2) {
rpc->fault(ctx, 500, "Invalid Parameters");
return;
+ } else if (nparams < 3) {
+ attrs.s = 0;
+ attrs.len = 0;
}
if(ds_add_dst(group, &dest, flags, &attrs) != 0) {