]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fixup #17638: ignore EINVAL from FreeBSD jails without ::1
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>
Thu, 19 Nov 2015 08:20:01 +0000 (19:20 +1100)
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>
Thu, 19 Nov 2015 08:20:01 +0000 (19:20 +1100)
In my testing, an IPv6-only FreeBSD jail without ::1 returned EINVAL
from tor_ersatz_socketpair. Let's not fail the unit test because of
this - it would only ever use tor_socketpair() anyway.

src/test/test_util.c

index eecc50a28751584e64376704072ffe1533a15c74..05c57c32a791c474d9b7ba2ba9967538a60ebb1f 100644 (file)
@@ -4425,6 +4425,11 @@ 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)) {
+    /* 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]));