apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@manyfish.co.uk>
Subject Re: unrecognized getnameinfo() bugs dealing with IPv4-mapped addresses
Date Thu, 20 May 2004 12:24:56 GMT
On Thu, May 20, 2004 at 01:12:00PM +0100, Colm MacCarthaigh wrote:
> On Thu, May 20, 2004 at 07:37:00AM -0400, Jeff Trawick wrote:
> >      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];
> 
> I don't think that's correct, s6_addr is only 8-bits wide, but we need
> 32 bits here.  sockaddr->sa.sin6.sin6_addr.s6_addr[3] will get you bits
> 24 through 32 when we want 96 through 128 :)
> 
> We can't use the s6_addr32 because it's non-standard (and depends on
> _KERNEL on the BSD's I think - though havn't checked recently). I knew
> there was some reason I used the ipaddr_ptr the first time ;p

Ha, well spotted, teach me to try and "optimise" things. I really only
looked at the line after seeing the uint32_t there... so let's just use
the original with s/uint32_t/apr_uint32_t.

joe

Mime
View raw message