diff options
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 187cb23125..eecc50a287 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4342,9 +4342,6 @@ 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) @@ -4361,7 +4358,7 @@ test_util_socket(void *arg) (void)arg; fd1 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 0, 0); - if (SOCK_ERR_IS_EPROTO(fd1)) { + if (tor_socket_errno(fd1) == SOCK_ERRNO(EPROTONOSUPPORT)) { /* Assume we're on an IPv4-only or IPv6-only system, and give up now. */ goto done; } @@ -4424,11 +4421,10 @@ test_util_socketpair(void *arg) int socketpair_result = 0; socketpair_result = tor_socketpair_fn(family, SOCK_STREAM, 0, fds); - if (ersatz && ERRNO_IS_EPROTO(-socketpair_result)) { - /* Assume we're on an IPv6-only system, and give up now. - * (tor_ersatz_socketpair uses IPv4.) */ - goto done; - } + /* If there is no 127.0.0.1 or ::1, tor_ersatz_socketpair will and must fail. + * 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.) */ tt_int_op(0, OP_EQ, socketpair_result); tt_assert(SOCKET_OK(fds[0])); tt_assert(SOCKET_OK(fds[1])); @@ -4449,8 +4445,6 @@ test_util_socketpair(void *arg) tor_close_socket(fds[1]); } -#undef SOCKET_EPROTO - static void test_util_max_mem(void *arg) { |