summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2012-11-05 22:07:51 +0000
committerJoe Orton <jorton@apache.org>2012-11-05 22:07:51 +0000
commit708b950567b83e2a4be18c11406542381e6743a1 (patch)
tree6c3654b713481c4d0ea6e4455845e38b60ea73f6 /network_io
parent6bf4d001cc195e7ab744a09afbb86c126f144654 (diff)
downloadapr-708b950567b83e2a4be18c11406542381e6743a1.tar.gz
* 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: https://svn.apache.org/repos/asf/apr/apr/trunk@1405985 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/unix/sockaddr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c
index e6c103531..9e98821ee 100644
--- a/network_io/unix/sockaddr.c
+++ b/network_io/unix/sockaddr.c
@@ -1068,7 +1068,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;
@@ -1080,7 +1080,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] &&