]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Fix segfault by making the initialization of the connection after...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 25 Sep 2018 22:26:32 +0000 (00:26 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Fri, 28 Sep 2018 06:51:42 +0000 (09:51 +0300)
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

index 4411db7b89ed5caa396638cf6ea6b9d100af7d29..6b0a8ffa03ca3e90040ec6f73598aa96c5922566 100644 (file)
@@ -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;