From 077b26385854feb701950d020e382c254b803e75 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 23 Jan 2015 12:50:49 +0100 Subject: [PATCH] path: received parameter enclosed in square brackets if ipv6 - 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 --- modules/path/path.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/path/path.c b/modules/path/path.c index 3ec28c471e7..6c350ae48ed 100644 --- a/modules/path/path.c +++ b/modules/path/path.c @@ -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) { @@ -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");