trawick 01/03/15 11:43:55
Modified: network_io/unix sa_common.c
test testipsub.c
Log:
fix some "issues" with IPv4-mapped IPv6 addresses in apr_ipsubnet_*()
Revision Changes Path
1.31 +9 -7 apr/network_io/unix/sa_common.c
Index: sa_common.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sa_common.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- sa_common.c 2001/03/15 18:28:04 1.30
+++ sa_common.c 2001/03/15 19:43:46 1.31
@@ -561,6 +561,8 @@
/* supported flavors of IP:
*
* . IPv6 numeric address string (e.g., "fe80::1")
+ *
+ * IMPORTANT: Don't store IPv4-mapped IPv6 address as an IPv6 address.
*
* . IPv4 numeric address string (e.g., "127.0.0.1")
*
@@ -573,6 +575,13 @@
#if APR_HAVE_IPV6
rc = apr_inet_pton(AF_INET6, ipstr, ipsub->sub);
if (rc == 1) {
+ if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ipsub->sub)) {
+ /* apr_ipsubnet_test() assumes that we don't create IPv4-mapped
IPv6
+ * addresses; this of course forces the user to specify IPv4
addresses
+ * in a.b.c.d style instead of ::ffff:a.b.c.d style.
+ */
+ return APR_EBADIP;
+ }
ipsub->family = AF_INET6;
}
else
@@ -580,13 +589,6 @@
{
rc = apr_inet_pton(AF_INET, ipstr, ipsub->sub);
if (rc == 1) {
- if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ipsub->sub)) {
- /* apr_ipsubnet_test() assumes that we don't create
IPv4-mapped IPv6
- * addresses; this of course forces the user to specify IPv4
addresses
- * in a.b.c.d style instead of ::ffff:a.b.c.d style.
- */
- return APR_EBADIP;
- }
ipsub->family = AF_INET;
}
}
1.2 +4 -0 apr/test/testipsub.c
Index: testipsub.c
===================================================================
RCS file: /home/cvs/apr/test/testipsub.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testipsub.c 2001/03/15 18:27:47 1.1
+++ testipsub.c 2001/03/15 19:43:52 1.2
@@ -93,6 +93,7 @@
#if APR_HAVE_IPV6
,{"::1", NULL, APR_SUCCESS}
,{"::1", "20", APR_SUCCESS}
+ ,{"::ffff:9.67.113.15", NULL, APR_EBADIP} /* yes, this
is goodness */
,{"fe80::", "16", APR_SUCCESS}
,{"fe80::", "255.0.0.0", APR_EBADMASK}
,{"fe80::1", "0", APR_EBADMASK}
@@ -103,6 +104,7 @@
,{"fe80::1", "129", APR_EBADMASK}
#else
/* do some IPv6 stuff and verify that it fails with APR_EBADIP */
+ ,{"::ffff:9.67.113.15", NULL, APR_EBADIP}
#endif
};
int i;
@@ -163,6 +165,8 @@
,{"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"}
+ ,{"127.0.0.1", NULL, APR_INET6,
"::ffff:127.0.0.1", "fe80::1"}
+ ,{"127.0.0.1", "8", APR_INET6,
"::ffff:127.0.0.1", "fe80::1"}
#endif
};
apr_ipsubnet_t *ipsub;