Skip to content

Commit

Permalink
path: received parameter enclosed in square brackets if ipv6
Browse files Browse the repository at this point in the history
- received should be useless for ipv4, but still can be enforced from
  config, so has to be well formatted because it is followed by a port
- reported by Sebastian Damm

(cherry picked from commit 077b263)
(cherry picked from commit 6a98873)
  • Loading branch information
miconda committed Feb 4, 2015
1 parent e499db5 commit 8ee34da
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/path/path.c
Expand Up @@ -67,7 +67,7 @@ static int prepend_path(struct sip_msg* _m, str *user, path_param_t param, str *

/* maximum possible length of suffix */
suffix_len = strlen(";lr;received=sip::12345%3Btransport%3Dsctp;ob;>\r\n")
+ IP_ADDR_MAX_STR_SIZE + (add_params ? add_params->len : 0) + 1;
+ IP_ADDR_MAX_STR_SIZE + 2 + (add_params ? add_params->len : 0) + 1;

cp = suffix = pkg_malloc(suffix_len);
if (!suffix) {
Expand All @@ -86,8 +86,13 @@ static int prepend_path(struct sip_msg* _m, str *user, path_param_t param, str *
else
proto_str = NULL;

cp += sprintf(cp, ";received=sip:%s:%hu%s", ip_addr2a(&_m->rcv.src_ip),
_m->rcv.src_port, proto_str ? : "");
if(_m->rcv.src_ip.af==AF_INET6) {
cp += sprintf(cp, ";received=sip:[%s]:%hu%s", ip_addr2a(&_m->rcv.src_ip),
_m->rcv.src_port, proto_str ? : "");
} else {
cp += sprintf(cp, ";received=sip:%s:%hu%s", ip_addr2a(&_m->rcv.src_ip),
_m->rcv.src_port, proto_str ? : "");
}
break;
case PATH_PARAM_OB:
cp += sprintf(cp, ";ob");
Expand Down

0 comments on commit 8ee34da

Please sign in to comment.