apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r1405985 - in /apr/apr/trunk: CHANGES network_io/unix/sockaddr.c test/testipsub.c
Date Mon, 05 Nov 2012 22:07:52 GMT
Author: jorton
Date: Mon Nov  5 22:07:51 2012
New Revision: 1405985

URL: http://svn.apache.org/viewvc?rev=1405985&view=rev
Log:
* network_io/unix/sockaddr.c (apr_ipsubnet_test): Fix false positive
  when testing a v4 subnet against a v6 address.

* test/testipsub.c (test_interesting_subnets): Add test.

PR: 54047

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/network_io/unix/sockaddr.c
    apr/apr/trunk/test/testipsub.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1405985&r1=1405984&r2=1405985&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Mon Nov  5 22:07:51 2012
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 2.0.0
 
+  *) Fix apr_ipsubnet_test() false positives when comparing IPv4
+     subnet representation against an IPv6 address.  PR 54047.  [Joe Orton]
+
   *) apr_socket_accept_filter(): The 2nd and 3rd arguments are now 
      const char * instead of char *.  [Jeff Trawick]
 

Modified: apr/apr/trunk/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockaddr.c?rev=1405985&r1=1405984&r2=1405985&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockaddr.c (original)
+++ apr/apr/trunk/network_io/unix/sockaddr.c Mon Nov  5 22:07:51 2012
@@ -1068,7 +1068,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_i
     /* XXX This line will segv on Win32 build with APR_HAVE_IPV6,
      * but without the IPV6 drivers installed.
      */
-    if (sa->sa.sin.sin_family == AF_INET) {
+    if (sa->family == AF_INET) {
         if (ipsub->family == AF_INET &&
             ((sa->sa.sin.sin_addr.s_addr & ipsub->mask[0]) == ipsub->sub[0]))
{
             return 1;
@@ -1080,7 +1080,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_i
             return 1;
         }
     }
-    else {
+    else if (sa->family == AF_INET6 && ipsub->family == AF_INET6) {
         apr_uint32_t *addr = (apr_uint32_t *)sa->ipaddr_ptr;
 
         if ((addr[0] & ipsub->mask[0]) == ipsub->sub[0] &&

Modified: apr/apr/trunk/test/testipsub.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testipsub.c?rev=1405985&r1=1405984&r2=1405985&view=diff
==============================================================================
--- apr/apr/trunk/test/testipsub.c (original)
+++ apr/apr/trunk/test/testipsub.c Mon Nov  5 22:07:51 2012
@@ -119,6 +119,7 @@ static void test_interesting_subnets(abt
         ,{"127",              NULL,            APR_INET,  "127.0.0.1",           "10.1.2.3"}
         ,{"127.0.0.1",        "8",             APR_INET,  "127.0.0.1",           "10.1.2.3"}
 #if APR_HAVE_IPV6
+        ,{"38.0.0.0",         "8",             APR_INET6, "::ffff:38.1.1.1",     "2600::1"}
/* PR 54047 */
         ,{"fe80::",           "8",             APR_INET6, "fe80::1",             "ff01::1"}
         ,{"ff01::",           "8",             APR_INET6, "ff01::1",             "fe80::1"}
         ,{"3FFE:8160::",      "28",            APR_INET6, "3ffE:816e:abcd:1234::1", "3ffe:8170::1"}



Mime
View raw message