diff options
author | Jeff Trawick <trawick@apache.org> | 2011-03-13 14:12:03 +0000 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2011-03-13 14:12:03 +0000 |
commit | 64d2c7df5c8e31836ffcc259a45cfb3977bc9f70 (patch) | |
tree | 0f8fd52587c4668df6ed33de522d8f6f3786d135 /network_io | |
parent | c3ed3ab1b5117d3b19b7d1121027a33c55c1728a (diff) | |
download | apr-64d2c7df5c8e31836ffcc259a45cfb3977bc9f70.tar.gz |
apr_sockaddr_info_get() on AIX: Fix a problem which could set
the port field in the native socket address to 1 when 0 was
specified.
An AIX-specific hack to work around a service name limitation
used "1" as the service name, but the 1 was not replaced later.
PR: 46964
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1081120 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/unix/sockaddr.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 77cfba98c..28280be85 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -58,6 +58,15 @@ struct apr_ipsubnet_t { #define GETHOSTBYNAME_BUFLEN 512 #endif +#ifdef _AIX +/* Some levels of AIX getaddrinfo() don't like servname = "0", so + * set servname to "1" when port is 0 and fix it up later. + */ +#define AIX_SERVNAME_HACK 1 +#else +#define AIX_SERVNAME_HACK 0 +#endif + #ifdef _WIN32_WCE /* XXX: BS solution. Need an HAVE_GETSERVBYNAME and actually * do something here, to provide the obvious proto mappings. @@ -138,6 +147,11 @@ void apr_sockaddr_vars_set(apr_sockaddr_t *addr, int family, apr_port_t port) addr->sa.sin.sin_port = htons(port); addr->port = port; } +#if AIX_SERVNAME_HACK + else { + addr->sa.sin.sin_port = htons(port); + } +#endif if (family == APR_INET) { addr->salen = sizeof(struct sockaddr_in); @@ -339,16 +353,12 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa, hints.ai_flags |= AI_NUMERICHOST; #endif #else -#ifdef _AIX - /* But current AIX getaddrinfo() doesn't like servname = "0"; - * the "1" won't hurt since we use the port parameter to fill - * in the returned socket addresses later - */ +#if AIX_SERVNAME_HACK if (!port) { servname = "1"; } else -#endif /* _AIX */ +#endif /* AIX_SERVNAME_HACK */ servname = apr_itoa(p, port); #endif /* OSF1 */ } |