Module: kamailio
Branch: master
Commit: fd79adb4975fc0799fe8488d1dd1a771041a0939
URL: 
https://github.com/kamailio/kamailio/commit/fd79adb4975fc0799fe8488d1dd1a771041a0939

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2015-12-10T09:33:32+01:00

dispatcher: proper handling of socket parameter when is not last in attrs

- parsing socket function expects a null terminated string

---

Modified: modules/dispatcher/dispatch.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/fd79adb4975fc0799fe8488d1dd1a771041a0939.diff
Patch: 
https://github.com/kamailio/kamailio/commit/fd79adb4975fc0799fe8488d1dd1a771041a0939.patch

---

diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c
index 1188692..3638a9c 100644
--- a/modules/dispatcher/dispatch.c
+++ b/modules/dispatcher/dispatch.c
@@ -255,6 +255,7 @@ int add_dest2list(int id, str uri, int flags, int priority, 
str *attrs,
        int orig_id = 0, orig_nr = 0;
        str host;
        int port, proto;
+       char c = 0;
        ds_set_t *orig_ds_lists = ds_lists[list_idx];
 
        /* check uri */
@@ -329,11 +330,23 @@ int add_dest2list(int id, str uri, int flags, int 
priority, str *attrs,
 
        /* check socket attribute */
        if (dp->attrs.socket.s && dp->attrs.socket.len > 0) {
+               /* parse_phostport(...) expects 0-terminated string
+                * - after socket parameter is either ';' or '\0' */
+               if(dp->attrs.socket.s[dp->attrs.socket.len]!='\0') {
+                       c = dp->attrs.socket.s[dp->attrs.socket.len];
+                       dp->attrs.socket.s[dp->attrs.socket.len] = '\0';
+               }
                if (parse_phostport(dp->attrs.socket.s, &host.s, &host.len,
                                &port, &proto)!=0) {
                        LM_ERR("bad socket <%.*s>\n", dp->attrs.socket.len, 
dp->attrs.socket.s);
+                       if(c!=0) {
+                               dp->attrs.socket.s[dp->attrs.socket.len] = c;
+                       }
                        goto err;
                }
+               if(c!=0) {
+                       dp->attrs.socket.s[dp->attrs.socket.len] = c;
+               }
                dp->sock = grep_sock_info( &host, (unsigned short)port, proto);
                if (dp->sock==0) {
                        LM_ERR("non-local socket <%.*s>\n", 
dp->attrs.socket.len, dp->attrs.socket.s);


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to