]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed'
authorNick Mathewson <nickm@torproject.org>
Thu, 19 Nov 2015 16:19:31 +0000 (11:19 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 19 Nov 2015 16:19:31 +0000 (11:19 -0500)
1  2 
src/test/test_util.c

index 05c57c32a791c474d9b7ba2ba9967538a60ebb1f,187cb23125b58adda51b7fc63e165e97679e7806..4cf2f9bda16278bec6b6d2dfb016184972c95a4d
@@@ -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 (-socketpair_result == SOCK_ERRNO(EINVAL)) {
 +  /* 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.) */
 -    /* Assume we're on an IPv6-only system, and give up now.
 -     * (tor_ersatz_socketpair uses IPv4.) */
+   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);