From: Florian Sauerteig Date: Tue, 6 Oct 2015 17:40:22 +0000 (+0200) Subject: chan_sip: Fix port parsing for IPv6 addresses in SIP Via headers. X-Git-Tag: 11.21.0-rc1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9354c1a64f567e552b3e0e376610a0503231275a;p=thirdparty%2Fasterisk.git chan_sip: Fix port parsing for IPv6 addresses in SIP Via headers. If a Via header containes an IPv6 address and a port number is ommitted, as it is the standard port, we now leave the port empty and to not set it to the value after the first colon of the IPv6 address. ASTERISK-25443 #close Change-Id: Ie3c2f05471cd006bf04ed15598589c09577b1e70 --- diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c index 42bb04deb5..9b435d00c9 100644 --- a/channels/sip/reqresp_parser.c +++ b/channels/sip/reqresp_parser.c @@ -2323,7 +2323,7 @@ struct sip_via *parse_via(const char *header) /* store the port, we have to handle ipv6 addresses containing ':' * characters gracefully */ - if (((parm = strchr(v->sent_by, ']')) && *(++parm) == ':') || (parm = strchr(v->sent_by, ':'))) { + if (((parm = strchr(v->sent_by, ']')) && *(++parm) == ':') || (!(parm = strchr(v->sent_by, ']')) && (parm = strchr(v->sent_by, ':')))) { char *endptr; v->port = strtol(++parm, &endptr, 10);