diff options
author | Jeff Trawick <trawick@apache.org> | 2004-05-21 22:10:51 +0000 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2004-05-21 22:10:51 +0000 |
commit | bbf74243db698cb52939e053ff1808a9f3205080 (patch) | |
tree | 5e013d605816d24cfe8d639f7c902ab71fb9fe68 | |
parent | e3ec8f46356ae97f340ceb34ffbd6c53c073facc (diff) | |
download | apr-bbf74243db698cb52939e053ff1808a9f3205080.tar.gz |
backport this from 1.0-dev
Don't assume getnameinfo() can handle IPv4-mapped IPv6 addresses
on any platforms.
Submitted by: Jeff Trawick, Joe Orton, Colm MacC�rthaigh <colm stdlib.net>
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/APR_0_9_BRANCH@65106 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | build/apr_network.m4 | 74 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | network_io/unix/sockaddr.c | 7 |
4 files changed, 7 insertions, 79 deletions
@@ -1,5 +1,9 @@ Changes with APR 0.9.5 + *) Don't assume getnameinfo() can handle IPv4-mapped IPv6 addresses + on any platforms. + [Jeff Trawick, Joe Orton, Colm MacCárthaigh <colm stdlib.net>] + *) Support setuid, setgid and sticky file permissions bits on Unix. [André Malo] diff --git a/build/apr_network.m4 b/build/apr_network.m4 index caf52a8fa..58ae115d4 100644 --- a/build/apr_network.m4 +++ b/build/apr_network.m4 @@ -141,80 +141,6 @@ fi ]) dnl -dnl check for getnameinfo() that properly resolves IPv4-mapped IPv6 addresses -dnl -dnl Darwin is known not to map them correctly -dnl -AC_DEFUN(APR_CHECK_GETNAMEINFO_IPV4_MAPPED,[ - AC_CACHE_CHECK(whether getnameinfo resolves IPv4-mapped IPv6 addresses, - ac_cv_getnameinfo_ipv4_mapped,[ - AC_TRY_RUN( [ -#ifdef HAVE_NETDB_H -#include <netdb.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif - -void main(void) { - struct sockaddr_in6 sa = {0}; - struct in_addr ipv4; -#if defined(NI_MAXHOST) - char hbuf[NI_MAXHOST]; -#else - char hbuf[256]; -#endif - unsigned int *addr32; - int error; - - ipv4.s_addr = inet_addr("127.0.0.1"); - - sa.sin6_family = AF_INET6; - sa.sin6_port = 0; - - addr32 = (unsigned int *)&sa.sin6_addr; - addr32[2] = htonl(0x0000FFFF); - addr32[3] = ipv4.s_addr; - -#ifdef SIN6_LEN - sa.sin6_len = sizeof(sa); -#endif - - error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa), - hbuf, sizeof(hbuf), NULL, 0, - NI_NAMEREQD); - if (error) { - exit(1); - } else { - exit(0); - } -} -],[ - ac_cv_getnameinfo_ipv4_mapped="yes" -],[ - ac_cv_getnameinfo_ipv4_mapped="no" -],[ - ac_cv_getnameinfo_ipv4_mapped="yes" -])]) -if test "$ac_cv_getnameinfo_ipv4_mapped" = "no"; then - AC_DEFINE(GETNAMEINFO_IPV4_MAPPED_FAILS, 1, - [Define if getnameinfo does not map IPv4 address correctly]) -fi -]) - -dnl dnl check for presence of retrans/retry variables in the res_state structure dnl AC_DEFUN(APR_CHECK_RESOLV_RETRANS,[ diff --git a/configure.in b/configure.in index b898c8411..5bae92cb1 100644 --- a/configure.in +++ b/configure.in @@ -1841,7 +1841,6 @@ else if test "x$have_sockaddr_in6" = "x1"; then if test "x$ac_cv_working_getaddrinfo" = "xyes"; then if test "x$ac_cv_working_getnameinfo" = "xyes"; then - APR_CHECK_GETNAMEINFO_IPV4_MAPPED have_ipv6="1" ipv6_result="yes" else diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 281c89d9f..614ffb813 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -603,11 +603,10 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, * a numeric address string if it fails to resolve the host name; * that is *not* what we want here * - * Additionally, if we know getnameinfo() doesn't handle IPv4-mapped - * IPv6 addresses correctly, drop down to IPv4 before calling - * getnameinfo(). + * For IPv4-mapped IPv6 addresses, drop down to IPv4 before calling + * getnameinfo() to avoid getnameinfo bugs (MacOS X, glibc). */ -#ifdef GETNAMEINFO_IPV4_MAPPED_FAILS +#if APR_HAVE_IPV6 if (sockaddr->family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sockaddr->sa.sin6.sin6_addr)) { struct apr_sockaddr_t tmpsa; |