From: Nick Mathewson Date: Thu, 19 Nov 2015 16:19:31 +0000 (-0500) Subject: Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed' X-Git-Tag: tor-0.2.8.1-alpha~229 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35bfd782eae29646dcf69e6fff84030721ff7a7d;p=thirdparty%2Ftor.git Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed' --- 35bfd782eae29646dcf69e6fff84030721ff7a7d diff --cc src/test/test_util.c index 05c57c32a7,187cb23125..4cf2f9bda1 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@@ -4421,16 -4424,12 +4424,17 @@@ test_util_socketpair(void *arg int socketpair_result = 0; socketpair_result = tor_socketpair_fn(family, SOCK_STREAM, 0, fds); + /* 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.) */ - if (-socketpair_result == SOCK_ERRNO(EINVAL)) { + if (ersatz && ERRNO_IS_EPROTO(-socketpair_result)) { - /* Assume we're on an IPv6-only system, and give up now. - * (tor_ersatz_socketpair uses IPv4.) */ + /* 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);