[sr-dev] [kamailio/kamailio] t_forward_nonack not decoding/unescaping URI (#2255)

Julien Chavanton notifications at github.com
Wed Mar 18 19:01:44 CET 2020



### Description
SIP OPTION relayed using `t_forward_nonack()` not being URI decoded


<!--
Explain what you did, what you expected to happen, and what actually happened.
-->

### Troubleshooting

#### Reproduction

register with PATH and use SIP OPTION keep alive
or simply send relay a SIP OPTIONS with a route.



#### Debugging Data

<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.

  gdb /path/to/kamailio /path/to/corefile
  bt full
  info locals
  list

If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->

```#1  0x00007fa3067a998f in t_forward_nonack (t=0x7fa3246fce88, 
    p_msg=0x7fa3885aa1c0, proxy=0x0, proto=0) at t_fwd.c:1729
1729				raise(SIGSEGV);
(gdb) l
1724				ser_error=MIN_int(lowest_ret, E_CFG);
1725				return -1;
1726			}
1727			if(lowest_ret!=E_CFG) {
1728				LM_ERR("failure to add branches\n");
1729				raise(SIGSEGV);  << raising exception to get the coredump
1730			}
1731			ser_error=lowest_ret;
1732			return lowest_ret;
1733		}

```

#### Log Messages

```
4(34) ERROR: tm [ut.h:245]: uri2dst2(): bad_uri: sip:247.25.169.51:52307%3Btransport%3Dtls
4(34) ERROR: tm [t_fwd.c:1728]: t_forward_nonack(): failure to add branches
```

### Possible Solutions

This patch can fix the problem from the routing script :
``` 
if (is_method("OPTIONS") && uri!=myself) {
        $var(path_uri) = $(hdr(Route){re.subst,/<(.*)>/\1/});                                                                                                                                                       
        if (defined $(var(path_uri){uri.params}) && $(var(path_uri){uri.params}{param.value,received})         != "") {
                $var(received) = $(var(path_uri){uri.params}{param.value,received});
                if ($var(received) =~ "sip:.*:.*") {
                        $du = $var(received);           
                $avp(received) = $(var(path_uri){uri.params}{param.value,received});
                avp_subst("$avp(received)", "/%3Btransport%3Dtcp/;transport=tcp/ig");
                if ($avp(received) =~ "sip:.*:.*") {
                        $du = $avp(received);           
                }
        }
        t_relay();
}
```

### Additional Information

tested on 5.3.2, something changed during 5.3.0.dev, I will try to pin point the commit

-- 
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/2255
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200318/82618041/attachment.html>


More information about the sr-dev mailing list