diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2012-12-11 12:06:43 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2012-12-11 12:06:43 +0000 |
commit | b790a1fca0cee725ed29b31bd68d7f15252f6a0f (patch) | |
tree | 39e1ecbe6c9a0c845433e1a39198856e4eba6132 | |
parent | 56617c0de8f76ce44c0769fe01360d5ec84e3304 (diff) | |
download | libapr-b790a1fca0cee725ed29b31bd68d7f15252f6a0f.tar.gz |
Merge 1405985 from trunk:
* 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
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1420116 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | network_io/unix/sockaddr.c | 4 | ||||
-rw-r--r-- | test/testipsub.c | 1 |
3 files changed, 9 insertions, 2 deletions
@@ -1,6 +1,12 @@ -*- coding: utf-8 -*- Changes for APR 1.4.7 + *) Remove unused code, fix strict C compliance bug in SHA-256 + implementation. [Jan Kaluza <jkaluza redhat.com>] + + *) Fix apr_ipsubnet_test() false positives when comparing IPv4 + subnet representation against an IPv6 address. PR 54047. [Joe Orton] + *) apr_socket_accept_filter: Return success when trying to again set the filter to the same value as before, avoiding an unhelpful APR_EINVAL. PR 37863. [Jeff Trawick] diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 82de83769..a5cb8221c 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -1028,7 +1028,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa) /* 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; @@ -1040,7 +1040,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa) 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] && diff --git a/test/testipsub.c b/test/testipsub.c index 8fd36721d..804bb3dcd 100644 --- a/test/testipsub.c +++ b/test/testipsub.c @@ -119,6 +119,7 @@ static void test_interesting_subnets(abts_case *tc, void *data) ,{"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"} |