--------------------- PatchSet 4308 Date: 2007/04/22 07:47:20 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Fix some bugs in masking. Members: lib/IPAddress.cc:1.1.2.27->1.1.2.28 Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/Attic/IPAddress.cc,v retrieving revision 1.1.2.27 retrieving revision 1.1.2.28 diff -u -r1.1.2.27 -r1.1.2.28 --- squid3/lib/IPAddress.cc 14 Apr 2007 12:25:23 -0000 1.1.2.27 +++ squid3/lib/IPAddress.cc 22 Apr 2007 07:47:20 -0000 1.1.2.28 @@ -1,6 +1,6 @@ /* - * $Id: IPAddress.cc,v 1.1.2.27 2007/04/14 12:25:23 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.28 2007/04/22 07:47:20 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -119,8 +119,18 @@ /* Let's scan all the bits from Most Significant to Least */ /* Until we find an "0" bit. Then, we return */ + shift=0; - for (shift=0;shift0 && p >= (uint8_t*)&m_SocketAddr.sin6_addr ; clearbits-=8, p-- ) { - *p &= ((0xFF << clearbits) & 0xFF); + if(clearbits < 8) { + *p &= ((0xFF << clearbits) & 0xFF); + } } + /* we have found a situation where mask forms or destroys a IPv4 map. */ + check4Mapped(); + return true; } @@ -423,9 +441,9 @@ return *this; }; -#ifdef USE_IPV6 void IPAddress::check4Mapped() { +#ifdef USE_IPV6 /* check for ::ffff:x.x.x.x IPv4-mapped addresses */ if( 0 == memcmp(&m_SocketAddr.sin6_addr, &"\0x00000000\0x00000000\0x0000FFFF", sizeof(struct in6_addr)-sizeof(struct in_addr) ) ) { @@ -442,9 +460,10 @@ /* FIXME INET6 : maybe other tests can apply if the IPA was mapped in other ways */ /* I know of 2002:0.0.0.0:: mappings and possibly fe80::???? mappings */ - +#endif } +#ifdef USE_IPV6 IPAddress::IPAddress(sockaddr_in6 const &s) { memset(this,0,sizeof(IPAddress)); @@ -460,7 +479,6 @@ check4Mapped(); return *this; }; - #endif IPAddress::IPAddress(in_addr const &s)