]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-request - Fix payload assertions in http_client_request_send_mo...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 1 Dec 2020 09:25:09 +0000 (10:25 +0100)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 1 Dec 2020 16:38:47 +0000 (18:38 +0200)
When the request payload is finished, both req->payload_input and
req->payload_output could be NULL, so the assertions on those being not NULL
need to happen after the check for req->payload_finished.

This particularly causes problems with the
blocking http_client_request_send/finish_payload() API, which constantly
modifies req->payload_input and sets it to NULL to finish the output.

This caused a panic:

Panic: file http-client-request.c: line 1232 (http_client_request_send_more): assertion failed: (req->payload_input != NULL)

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

index 250417c93a62eb73bb5f0be947dbe3d081109fb0..0a471f7f5d56415922c7a63db153b7607ae5e35d 100644 (file)
@@ -1234,12 +1234,12 @@ int http_client_request_send_more(struct http_client_request *req,
        const char *error;
        uoff_t offset;
 
-       i_assert(req->payload_input != NULL);
-       i_assert(req->payload_output != NULL);
-
        if (req->payload_finished)
                return http_client_request_finish_payload_out(req);
 
+       i_assert(req->payload_input != NULL);
+       i_assert(req->payload_output != NULL);
+
        io_remove(&conn->io_req_payload);
 
        /* Chunked ostream needs to write to the parent stream's buffer */