diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-01-14 09:36:39 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-01-15 19:04:58 +0100 |
commit | 8583ace18fe8eda5491341f3ad74b2c9e91d1de5 (patch) | |
tree | 2ef1fb8cdaefa094c3b1bf4d3419060163ac07ca /src/IO | |
parent | f53fe9bc1fefbb15d3626912093112b511a632c8 (diff) |
Prevent nested calls to Tls_connect()
They may accidentally happen if a fd callback is still attached to the
connection socket while we wait in a FTLK dialog, causing another call
to Tls_connect() which will end up in an infinite loop.
Diffstat (limited to 'src/IO')
-rw-r--r-- | src/IO/tls_openssl.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/IO/tls_openssl.c b/src/IO/tls_openssl.c index d686c472..2da100fc 100644 --- a/src/IO/tls_openssl.c +++ b/src/IO/tls_openssl.c @@ -80,6 +80,7 @@ typedef struct { DilloUrl *url; SSL *ssl; bool_t connecting; + bool_t in_connect; } Conn_t; /* List of active TLS connections */ @@ -166,6 +167,7 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl) conn->url = a_Url_dup(url); conn->ssl = ssl; conn->connecting = TRUE; + conn->in_connect = FALSE; key = a_Klist_insert(&conn_list, conn); @@ -1076,6 +1078,13 @@ static void Tls_connect(int fd, int connkey) return; } + if (conn->in_connect) { + MSG("Tls_connect: nested call to Tls_connect(), aborting\n"); + abort(); + } else { + conn->in_connect = TRUE; + } + if (ERR_peek_error()) { unsigned long err; while ((err = ERR_get_error())) { @@ -1169,6 +1178,8 @@ static void Tls_connect(int fd, int connkey) MSG("Connection disappeared. Too long with a popup popped up?\n"); } } + + conn->in_connect = FALSE; } static void Tls_connect_cb(int fd, void *vconnkey) |