[svn-commits] mjordan: trunk r402506 - in /trunk: ./ channels/chan_iax2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 5 15:14:45 CST 2013


Author: mjordan
Date: Tue Nov  5 15:14:42 2013
New Revision: 402506

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402506
Log:
chan_iax2: Fix incorrect usage of ast_get_ip involving uninitialized struct

This started off as a fix for the failing IAX2 acl_call test in the Asterisk
Test Suite. When inspecting why that test was failing, it became clear that all
attempts to bind to any local loopback address was failing:

[Nov  2 15:56:28] VERBOSE[15787] chan_iax2.c:   == Binding IAX2 to address
                                 127.0.0.1:4569
[Nov  2 15:56:28] DEBUG[15787] netsock2.c: Splitting '127.0.0.1' into...
[Nov  2 15:56:28] DEBUG[15787] netsock2.c: ...host '127.0.0.1' and port ''.
[Nov  2 15:56:28] ERROR[15787] netsock2.c: getaddrinfo("127.0.0.1", "(null)",
                               ...): ai_family not supported
[Nov  2 15:56:28] WARNING[15787] acl.c: Unable to lookup '127.0.0.1'

While there's conceivably other ways for getaddrino to return EAI_FAMILY, the
most common way is if AF_INET, AF_INET6, or AF_UNSPEC is not provided as the
desired family. The culprit was the call to ast_get_ip, defined in acl.h. This
function uses the family from the passed in addr object (which it will also
populate when it returns!) when it eventually calls getaddrinfo.

This patch fixes the use of ast_get_ip that were not specifying the family in
chan_iax2. This prevents uninitialized use of the structure, so that the
addresses resolve correctly.

Review: https://reviewboard.asterisk.org/r/2991
........

Merged revisions 402505 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/channels/chan_iax2.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Nov  5 15:14:42 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402367,402387,402398,402416,402427,402429,402438,402452,402501,402503
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402367,402387,402398,402416,402427,402429,402438,402452,402501,402503,402505

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=402506&r1=402505&r2=402506
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Nov  5 15:14:42 2013
@@ -4272,7 +4272,7 @@
 				if (!strcasecmp(tmp->name, "host")) {
 					struct ast_sockaddr *hostaddr;
 
-					if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, 0)
+					if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
 						|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
 						/* No match */
 						ast_variables_destroy(var);
@@ -4394,7 +4394,7 @@
 				if (!strcasecmp(tmp->name, "host")) {
 					struct ast_sockaddr *hostaddr;
 
-					if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, 0)
+					if (!ast_sockaddr_resolve(&hostaddr, tmp->value, PARSE_PORT_FORBID, AST_AF_UNSPEC)
 						|| ast_sockaddr_cmp_addr(hostaddr, addr)) {
 						/* No match */
 						ast_variables_destroy(var);
@@ -12399,6 +12399,7 @@
 			port = IAX_DEFAULT_PORTNO;
 	}
 
+	addr.ss.ss_family = AST_AF_UNSPEC;
 	if (!ast_get_ip(&addr, host)) {
 		struct ast_netsock *sock;
 




More information about the svn-commits mailing list