Module: kamailio Branch: master Commit: 046126b4a90090bf5b8f9b517ba5218793e6b973 URL: https://github.com/kamailio/kamailio/commit/046126b4a90090bf5b8f9b517ba52187...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-08-11T12:36:02+02:00
topoh: check if via param has the expected prefix, otherwise skip
- GH #2437
---
Modified: src/modules/topoh/th_msg.c
---
Diff: https://github.com/kamailio/kamailio/commit/046126b4a90090bf5b8f9b517ba52187... Patch: https://github.com/kamailio/kamailio/commit/046126b4a90090bf5b8f9b517ba52187...
---
diff --git a/src/modules/topoh/th_msg.c b/src/modules/topoh/th_msg.c index 990128c01e..46fecb184a 100644 --- a/src/modules/topoh/th_msg.c +++ b/src/modules/topoh/th_msg.c @@ -408,7 +408,7 @@ int th_unmask_via(sip_msg_t *msg, str *cookie) if (th_uri_prefix_checks && (via->host.len!=th_ip.len || strncasecmp(via->host.s, th_ip.s, th_ip.len)!=0)) { - LM_DBG("via %d is not encoded",i); + LM_DBG("via %d is not encoded - skip\n",i); continue; }
@@ -418,9 +418,16 @@ int th_unmask_via(sip_msg_t *msg, str *cookie) LM_ERR("cannot find param in via %d\n", i); return -1; } - if(vp->value.len <= th_vparam_prefix.len) { - LM_ERR("invalid param len in via %d\n", i); - return -1; + if(th_vparam_prefix.len > 0) { + if(vp->value.len <= th_vparam_prefix.len) { + LM_DBG("shorter param len in via %d - skip\n", i); + continue; + } + if(strncmp(vp->value.s, th_vparam_prefix.s, + th_vparam_prefix.len) != 0) { + LM_DBG("no prefix in via %d - skip\n", i); + continue; + } } if(i==2) { out.s = th_mask_decode(vp->value.s, vp->value.len,