summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-11-05 21:14:42 +0000
committerMatthew Jordan <mjordan@digium.com>2013-11-05 21:14:42 +0000
commitf6bd22b0fd5846bdcfc6b01f480c9449e8bb364a (patch)
treedb4f875fc2e3d990e8513359904ebdf6f7cb241d /channels/chan_iax2.c
parentaa05fde22d24eebbf581cc3fa9e2e49ea6f93eb3 (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402506 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 1d0c3169e..e27cc14c6 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -4272,7 +4272,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct ast_sockaddr
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 @@ static struct iax2_user *realtime_user(const char *username, struct ast_sockaddr
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 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
port = IAX_DEFAULT_PORTNO;
}
+ addr.ss.ss_family = AST_AF_UNSPEC;
if (!ast_get_ip(&addr, host)) {
struct ast_netsock *sock;