Skip to content

Commit

Permalink
topoh: check if via param has the expected prefix, otherwise skip
Browse files Browse the repository at this point in the history
- GH #2437
  • Loading branch information
miconda committed Aug 11, 2020
1 parent 5267f4d commit 046126b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/modules/topoh/th_msg.c
Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down

0 comments on commit 046126b

Please sign in to comment.