]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
conn: Remove assert on new listener connection when retrying
authorDavid Goulet <dgoulet@torproject.org>
Tue, 1 Sep 2020 13:54:48 +0000 (09:54 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 1 Sep 2020 14:01:21 +0000 (10:01 -0400)
Opening a new listener connection can fail in many ways like a bind()
permission denied on a low port for instance.

And thus, we should expect to handle an error when creating a new one instead
of assert() on it.

To hit the removed assert:

  ORPort 80
  KeepBindCapabilities 0

Start tor. Then edit torrc:

  ORPort <some-IP>:80

HUP tor and the assert is hit.

Fixes #40073

Signed-off-by: David Goulet <dgoulet@torproject.org>
changes/ticket40073 [new file with mode: 0644]
src/core/mainloop/connection.c

diff --git a/changes/ticket40073 b/changes/ticket40073
new file mode 100644 (file)
index 0000000..30b028c
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (relay configuration, crash):
+    - Avoid a fatal assert() when failing to create a listener connection for an
+      address that was in use. Fixes bug 40073; bugfix on 0.3.5.1-alpha.
index 3595bba85c2564cc616f214293b8da05922a3b92..dcd4ec492faf4396112966feb014098e657b210e 100644 (file)
@@ -2923,7 +2923,14 @@ retry_all_listeners(smartlist_t *new_conns, int close_all_noncontrol)
                                                   &skip, &addr_in_use);
     }
 
-    tor_assert(new_conn);
+    /* There are many reasons why we can't open a new listener port so in case
+     * we hit those, bail early so tor can stop. */
+    if (!new_conn) {
+      log_warn(LD_NET, "Unable to create listener port: %s:%d",
+               fmt_addr(&r->new_port->addr), r->new_port->port);
+      retval = -1;
+      break;
+    }
 
     smartlist_add(new_conns, new_conn);