From: Stephan Bosch Date: Tue, 25 Sep 2018 22:26:32 +0000 (+0200) Subject: lib-http: client: Fix segfault by making the initialization of the connection after... X-Git-Tag: 2.3.9~1385 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c45400207c6a8aeb673b2dd91b3dba3398c1c58;p=thirdparty%2Fdovecot%2Fcore.git 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. --- 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;