From efd705ba594fa50f7b04c3f0b415fa4173b8a2b5 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Sat, 3 Apr 2021 21:54:53 +0200 Subject: [PATCH 1/3] fix crash on /connect /dev/null --- src/core/servers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/servers.c b/src/core/servers.c index a20d5f4a..143158ba 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -244,7 +244,9 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, server->no_reconnect = TRUE; server->connection_lost = TRUE; - server->connrec->last_failed_family = ip->family; + if (ip != NULL) { + server->connrec->last_failed_family = ip->family; + } server_connect_failed(server, errmsg2 ? errmsg2 : errmsg); g_free(errmsg2); } else { From 1e54b92220b0eba2af63226d41e9c8ea197677d0 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Sat, 3 Apr 2021 22:38:00 +0200 Subject: [PATCH 2/3] fix crash on /connect -tls fixes #1239 --- src/core/servers.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core/servers.c b/src/core/servers.c index 143158ba..77b88fa9 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -208,7 +208,7 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, const char *errmsg; char *errmsg2; char ipaddr[MAX_IP_LEN]; - int port; + int port = 0; g_return_if_fail(ip != NULL || unix_socket != NULL); @@ -222,12 +222,21 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, own_ip = IPADDR_IS_V6(ip) ? server->connrec->own_ip6 : server->connrec->own_ip4; port = server->connrec->proxy != NULL ? server->connrec->proxy_port : server->connrec->port; - handle = server->connrec->use_tls ? - net_connect_ip_ssl(ip, port, own_ip, server) : net_connect_ip(ip, port, own_ip); + handle = net_connect_ip(ip, port, own_ip); } else { handle = net_connect_unix(unix_socket); } + if (server->connrec->use_tls && handle != NULL) { + server->handle = net_sendbuffer_create(handle, 0); + handle = net_start_ssl(server); + if (handle == NULL) { + net_sendbuffer_destroy(server->handle, TRUE); + } else { + server->handle->handle = handle; + } + } + if (handle == NULL) { /* failed */ errmsg = g_strerror(errno); @@ -251,7 +260,8 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, g_free(errmsg2); } else { server->connrec->last_failed_family = 0; - server->handle = net_sendbuffer_create(handle, 0); + if (!server->connrec->use_tls) + server->handle = net_sendbuffer_create(handle, 0); if (server->connrec->use_tls) server_connect_callback_init_ssl(server, handle); else From 308400154b76897413f02987b9b8997fd6482af4 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Wed, 7 Apr 2021 21:36:27 +0200 Subject: [PATCH 3/3] fix crash on tls error --- src/core/servers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/servers.c b/src/core/servers.c index 77b88fa9..159af0e1 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -232,6 +232,7 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, handle = net_start_ssl(server); if (handle == NULL) { net_sendbuffer_destroy(server->handle, TRUE); + server->handle = NULL; } else { server->handle->handle = handle; }