Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed'

This commit is contained in:
Nick Mathewson
2015-11-19 11:19:31 -05:00
+8 -2
View File
@@ -4342,6 +4342,9 @@ fd_is_nonblocking(tor_socket_t fd)
}
#endif
#define ERRNO_IS_EPROTO(e) (e == SOCK_ERRNO(EPROTONOSUPPORT))
#define SOCK_ERR_IS_EPROTO(s) ERRNO_IS_EPROTO(tor_socket_errno(s))
/* Test for tor_open_socket*, using IPv4 or IPv6 depending on arg. */
static void
test_util_socket(void *arg)
@@ -4358,7 +4361,7 @@ test_util_socket(void *arg)
(void)arg;
fd1 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 0, 0);
if (tor_socket_errno(fd1) == SOCK_ERRNO(EPROTONOSUPPORT)) {
if (SOCK_ERR_IS_EPROTO(fd1)) {
/* Assume we're on an IPv4-only or IPv6-only system, and give up now. */
goto done;
}
@@ -4425,12 +4428,13 @@ test_util_socketpair(void *arg)
* Otherwise, we risk exposing a socketpair on a routable IP address. (Some
* BSD jails use a routable address for localhost. Fortunately, they have
* the real AF_UNIX socketpair.) */
if (-socketpair_result == SOCK_ERRNO(EINVAL)) {
if (ersatz && ERRNO_IS_EPROTO(-socketpair_result)) {
/* In my testing, an IPv6-only FreeBSD jail without ::1 returned EINVAL.
* Assume we're on a machine without 127.0.0.1 or ::1 and give up now. */
goto done;
}
tt_int_op(0, OP_EQ, socketpair_result);
tt_assert(SOCKET_OK(fds[0]));
tt_assert(SOCKET_OK(fds[1]));
tt_int_op(get_n_open_sockets(), OP_EQ, n + 2);
@@ -4450,6 +4454,8 @@ test_util_socketpair(void *arg)
tor_close_socket(fds[1]);
}
#undef SOCKET_EPROTO
static void
test_util_max_mem(void *arg)
{