[asterisk-commits] simon.perreault: branch 1.8 r280778 - /branches/1.8/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 3 14:54:08 CDT 2010
Author: simon.perreault
Date: Tue Aug 3 14:54:03 2010
New Revision: 280778
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=280778
Log:
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)
Modified:
branches/1.8/channels/chan_sip.c
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=280778&r1=280777&r2=280778
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Aug 3 14:54:03 2010
@@ -9872,12 +9872,22 @@
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);
@@ -14473,17 +14483,27 @@
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);
@@ -27041,10 +27061,12 @@
/* 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");
}
@@ -27052,7 +27074,7 @@
/* 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);
}
@@ -27061,14 +27083,14 @@
!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) */
More information about the asterisk-commits
mailing list