diff options
author | simon.perreault <simon.perreault@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-08-03 19:59:37 +0000 |
---|---|---|
committer | simon.perreault <simon.perreault@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-08-03 19:59:37 +0000 |
commit | fe5a3edcad951c6f09c25fcf03fe34c1e06ebc98 (patch) | |
tree | 945e28458b83cd27ddf97babe2156c878b15645c /channels/chan_sip.c | |
parent | 182b8b69af6cd674849399bd2c1266eacc9ddb5b (diff) |
Merged revisions 280778 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r280778 | simon.perreault | 2010-08-03 15:54:03 -0400 (Tue, 03 Aug 2010) | 9 lines
Fixed IPv6-related SIP parsing bugs.
(closes issue #17663)
Reported by: oej
Patches:
diff uploaded by sperreault (license 252)
diff2 uploaded by sperreault (license 252)
get_domain.diff uploaded by sperreault (license 252)
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@280780 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7ba217186..bba34fb4e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9875,12 +9875,22 @@ static int get_domain(const char *str, char *domain, int len) from = NULL; if (from) { + int bracket = 0; + /* Strip any params or options from user */ if ((a = strchr(from, ';'))) *a = '\0'; /* Strip port from domain if present */ - if ((a = strchr(from, ':'))) - *a = '\0'; + for (a = from; *a != '\0'; ++a) { + if (*a == ':' && bracket == 0) { + *a = '\0'; + break; + } else if (*a == '[') { + ++bracket; + } else if (*a == ']') { + --bracket; + } + } if ((a = strchr(from, '@'))) { *a = '\0'; ast_copy_string(domain, a + 1, len); @@ -14476,17 +14486,27 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi if ((ptr = strchr(refer_to, '@'))) { /* Separate domain */ char *urioption = NULL, *domain; + int bracket = 0; *ptr++ = '\0'; if ((urioption = strchr(ptr, ';'))) { /* Separate urioptions */ *urioption++ = '\0'; } - + domain = ptr; - if ((ptr = strchr(domain, ':'))) { /* Remove :port */ - *ptr = '\0'; + + /* Remove :port */ + for (; *ptr != '\0'; ++ptr) { + if (*ptr == ':' && bracket == 0) { + *ptr = '\0'; + break; + } else if (*ptr == '[') { + ++bracket; + } else if (*ptr == ']') { + --bracket; + } } - + SIP_PEDANTIC_DECODE(domain); SIP_PEDANTIC_DECODE(urioption); @@ -27073,10 +27093,12 @@ static int reload_config(enum channelreloadreason reason) /* First our default IP address */ if (!ast_sockaddr_isnull(&bindaddr)) { - add_sip_domain(ast_sockaddr_stringify(&bindaddr), SIP_DOMAIN_AUTO, NULL); + add_sip_domain(ast_sockaddr_stringify_addr(&bindaddr), + SIP_DOMAIN_AUTO, NULL); } else if (!ast_sockaddr_isnull(&internip)) { /* Our internal IP address, if configured */ - add_sip_domain(ast_sockaddr_stringify(&internip), SIP_DOMAIN_AUTO, NULL); + add_sip_domain(ast_sockaddr_stringify_addr(&internip), + SIP_DOMAIN_AUTO, NULL); } else { ast_log(LOG_NOTICE, "Can't add wildcard IP address to domain list, please add IP address to domain manually.\n"); } @@ -27084,7 +27106,7 @@ static int reload_config(enum channelreloadreason reason) /* If TCP is running on a different IP than UDP, then add it too */ if (!ast_sockaddr_isnull(&sip_tcp_desc.local_address) && !ast_sockaddr_cmp(&bindaddr, &sip_tcp_desc.local_address)) { - add_sip_domain(ast_sockaddr_stringify(&sip_tcp_desc.local_address), + add_sip_domain(ast_sockaddr_stringify_addr(&sip_tcp_desc.local_address), SIP_DOMAIN_AUTO, NULL); } @@ -27093,14 +27115,14 @@ static int reload_config(enum channelreloadreason reason) !ast_sockaddr_cmp(&bindaddr, &sip_tls_desc.local_address) && !ast_sockaddr_cmp(&sip_tcp_desc.local_address, &sip_tls_desc.local_address)) { - add_sip_domain(ast_sockaddr_stringify(&sip_tcp_desc.local_address), + add_sip_domain(ast_sockaddr_stringify_addr(&sip_tcp_desc.local_address), SIP_DOMAIN_AUTO, NULL); } /* Our extern IP address, if configured */ if (!ast_sockaddr_isnull(&externaddr)) { - add_sip_domain(ast_sockaddr_stringify(&externaddr), SIP_DOMAIN_AUTO, - NULL); + add_sip_domain(ast_sockaddr_stringify_addr(&externaddr), + SIP_DOMAIN_AUTO, NULL); } /* Extern host name (NAT traversal support) */ |