aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-09-01 09:54:48 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-09-01 10:01:21 -0400
commitea339227c27c03d7ced9e526d9e945708f432b22 (patch)
tree8db66c7981ea66f71f9c6da92e19c6a4fdca7abf /src
parent72484a4953d744754b3b6b025242ef668e3f017a (diff)
downloadtor-ea339227c27c03d7ced9e526d9e945708f432b22.tar.gz
tor-ea339227c27c03d7ced9e526d9e945708f432b22.zip
conn: Remove assert on new listener connection when retrying
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>
Diffstat (limited to 'src')
-rw-r--r--src/core/mainloop/connection.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index 3595bba85c..dcd4ec492f 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -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);