]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-connection - Fix crash in http_client_connection_server_close().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 19 Jul 2021 09:53:41 +0000 (11:53 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Nov 2021 12:34:39 +0000 (12:34 +0000)
The conn->peer member is only not NULL when the connection is associated with a
peer object. If it is not, http_client_connection_server_close() will crash.
Fixed by doing the peer->client operations only when there is an associated peer.

src/lib-http/http-client-connection.c

index 64b31088dca8d9f0c408ae4d85402e55f3525e3f..45dadac05f7b03020c1dc25c986cd1f13b5910b4 100644 (file)
@@ -153,7 +153,6 @@ http_client_connection_server_close(struct http_client_connection **_conn)
 {
        struct http_client_connection *conn = *_conn;
        struct http_client_peer *peer = conn->peer;
-       struct http_client *client = peer->client;
        struct http_client_request *req, **req_idx;
 
        e_debug(conn->event, "Server explicitly closed connection");
@@ -169,8 +168,12 @@ http_client_connection_server_close(struct http_client_connection **_conn)
        }
        array_clear(&conn->request_wait_list);
 
-       if (client != NULL && client->waiting)
-               io_loop_stop(client->ioloop);
+       if (peer != NULL) {
+               struct http_client *client = peer->client;
+
+               if (client->waiting)
+                       io_loop_stop(client->ioloop);
+       }
 
        http_client_connection_close(_conn);
 }