[sr-dev] [kamailio/kamailio] TOPOH module mask_ip errantly skips decoding encoded fields (#1222)

Joshua Riffle notifications at github.com
Wed Aug 30 17:39:20 CEST 2017


This patch on 4.4.6 tag worked ok for me by simply forcing a port number on the Via and Request URI prefixes:

```
diff --git modules/topoh/topoh_mod.c modules/topoh/topoh_mod.c
index 266cc46..7322cd6 100644
--- modules/topoh/topoh_mod.c
+++ modules/topoh/topoh_mod.c
@@ -160,7 +160,7 @@ static int mod_init(void)
    }

    /* 'SIP/2.0/UDP ' + ip + ';' + param + '=' + prefix (+ '\0') */
-   th_via_prefix.len = 12 + th_ip.len + 1 + th_vparam_name.len + 1
+   th_via_prefix.len = 12 + th_ip.len + 6 + th_vparam_name.len + 1
        + th_vparam_prefix.len;
    th_via_prefix.s = (char*)pkg_malloc(th_via_prefix.len+1);
    if(th_via_prefix.s==NULL)
@@ -169,7 +169,7 @@ static int mod_init(void)
        goto error;
    }
    /* 'sip:' + ip + ';' + param + '=' + prefix (+ '\0') */
-   th_uri_prefix.len = 4 + th_ip.len + 1 + th_uparam_name.len + 1
+   th_uri_prefix.len = 4 + th_ip.len + 6 + th_uparam_name.len + 1
        + th_uparam_prefix.len;
    th_uri_prefix.s = (char*)pkg_malloc(th_uri_prefix.len+1);
    if(th_uri_prefix.s==NULL)
@@ -180,21 +180,21 @@ static int mod_init(void)
    /* build via prefix */
    memcpy(th_via_prefix.s, "SIP/2.0/UDP ", 12);
    memcpy(th_via_prefix.s+12, th_ip.s, th_ip.len);
-   th_via_prefix.s[12+th_ip.len] = ';';
-   memcpy(th_via_prefix.s+12+th_ip.len+1, th_vparam_name.s,
+    memcpy(th_via_prefix.s+12+th_ip.len, ":5060;", 6);
+   memcpy(th_via_prefix.s+12+th_ip.len+6, th_vparam_name.s,
            th_vparam_name.len);
-   th_via_prefix.s[12+th_ip.len+1+th_vparam_name.len] = '=';
-   memcpy(th_via_prefix.s+12+th_ip.len+1+th_vparam_name.len+1,
+   th_via_prefix.s[12+th_ip.len+6+th_vparam_name.len] = '=';
+   memcpy(th_via_prefix.s+12+th_ip.len+6+th_vparam_name.len+1,
            th_vparam_prefix.s, th_vparam_prefix.len);
    th_via_prefix.s[th_via_prefix.len] = '\0';
    LM_DBG("VIA prefix: [%s]\n", th_via_prefix.s);
    /* build uri prefix */
    memcpy(th_uri_prefix.s, "sip:", 4);
    memcpy(th_uri_prefix.s+4, th_ip.s, th_ip.len);
-   th_uri_prefix.s[4+th_ip.len] = ';';
-   memcpy(th_uri_prefix.s+4+th_ip.len+1, th_uparam_name.s, th_uparam_name.len);
-   th_uri_prefix.s[4+th_ip.len+1+th_uparam_name.len] = '=';
-   memcpy(th_uri_prefix.s+4+th_ip.len+1+th_uparam_name.len+1,
+   memcpy(th_uri_prefix.s+4+th_ip.len, ":5060;", 6);
+   memcpy(th_uri_prefix.s+4+th_ip.len+6, th_uparam_name.s, th_uparam_name.len);
+   th_uri_prefix.s[4+th_ip.len+6+th_uparam_name.len] = '=';
+   memcpy(th_uri_prefix.s+4+th_ip.len+6+th_uparam_name.len+1,
            th_uparam_prefix.s, th_uparam_prefix.len);
    th_uri_prefix.s[th_uri_prefix.len] = '\0';
    LM_DBG("URI prefix: [%s]\n", th_uri_prefix.s);
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1222#issuecomment-326030933
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20170830/8bc5ef89/attachment.html>


More information about the sr-dev mailing list