apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: unrecognized getnameinfo() bugs dealing with IPv4-mapped addresses
Date Wed, 19 May 2004 09:43:38 GMT
Joe Orton wrote:
> On Tue, May 18, 2004 at 04:58:14PM -0400, Jeff Trawick wrote:
> 
>>Previously we went through this mess on older Mac OS X (DNS queries only?)
>>
>>I just realized that the glibc shipping with RHAS 2.1 and 3.0 (and surely 
>>many other Linux distros) has a problem with getnameinfo() for IPv4-mapped 
>>address for something defined in host file but not in DNS.
> 
> 
> I'll file a bug on that if you haven't already.

I haven't.

> --- network_io/unix/sockaddr.c	4 Mar 2004 16:17:25 -0000	1.49
> +++ network_io/unix/sockaddr.c	19 May 2004 09:19:07 -0000
> @@ -575,27 +575,24 @@
>       * 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

need #if APR_HAVE_IPV6 here since we use IPv6 macro and structures

>      if (sockaddr->family == AF_INET6 &&
>          IN6_IS_ADDR_V4MAPPED(&sockaddr->sa.sin6.sin6_addr)) {
> -        struct apr_sockaddr_t tmpsa;
> -        tmpsa.sa.sin.sin_family = AF_INET;
> -        tmpsa.sa.sin.sin_addr.s_addr = ((uint32_t *)sockaddr->ipaddr_ptr)[3];
> +        struct sockaddr_in tmpsa;
> +        tmpsa.sin_family = AF_INET;
> +        tmpsa.sin_addr.s_addr = sockaddr->sa.sin6.sin6_addr.s6_addr[3];
>  
> -        rc = getnameinfo((const struct sockaddr *)&tmpsa.sa,
> -                         sizeof(struct sockaddr_in),
> +        rc = getnameinfo((const struct sockaddr *)&tmpsa, sizeof(tmpsa),
>                           tmphostname, sizeof(tmphostname), NULL, 0,
>                           flags != 0 ? flags : NI_NAMEREQD);
>      }
>      else
> -#endif

#endif /* APR_HAVE_IPV6 */
> -    rc = getnameinfo((const struct sockaddr *)&sockaddr->sa, sockaddr->salen,
> -                     tmphostname, sizeof(tmphostname), NULL, 0,
> -                     flags != 0 ? flags : NI_NAMEREQD);
> +        rc = getnameinfo((const struct sockaddr *)&sockaddr->sa, sockaddr->salen,
> +                         tmphostname, sizeof(tmphostname), NULL, 0,
> +                         flags != 0 ? flags : NI_NAMEREQD);
> +
>      if (rc != 0) {
>          *hostname = NULL;

Mime
View raw message