From 2c45400207c6a8aeb673b2dd91b3dba3398c1c58 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Wed, 26 Sep 2018 00:26:32 +0200 Subject: [PATCH] lib-http: client: Fix segfault by making the initialization of the connection after SSL handshake reliable. Before, the connection was not guaranteed to be fully initialized after the SSL handshake. The problem would occur when the handshake finished while writing the SSL output stream. --- src/lib-http/http-client-connection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index de6e1d62ca..d983ab6e1d 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -979,8 +979,10 @@ static void http_client_connection_input(struct connection *_conn) i_assert(ret == 0); return; } + } - /* ready for first request */ + if (!conn->connect_succeeded) { + /* just got ready for first request */ http_client_connection_ready(conn); } @@ -1353,6 +1355,7 @@ http_client_connection_ready(struct http_client_connection *conn) const struct http_client_settings *set = &peer->client->set; e_debug(conn->event, "Ready for requests"); + i_assert(!conn->connect_succeeded); /* connected */ conn->connected = TRUE; -- 2.47.3