]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client: Fixed leak of ostream when request was resubmitted upon 417...
authorStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:29:03 +0000 (03:29 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:29:03 +0000 (03:29 +0300)
This would only occur when the server refuses Expect: 100-continue with a
417 response. The payload_output stream would be overwritten without being
freed first.

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

index 0d01d42e3af956edaf2ae46d7dbd41bf3bc77f75..080f5b7ad285573a4357ce47d6ac0085c5260eee 100644 (file)
@@ -364,6 +364,7 @@ static int http_client_request_send_real(struct http_client_request *req,
        int ret = 0;
 
        i_assert(!req->conn->output_locked);
+       i_assert(req->payload_output == NULL);
 
        str_append(rtext, req->method);
        str_append(rtext, " ");
@@ -594,6 +595,10 @@ void http_client_request_redirect(struct http_client_request *req,
                }
        }
 
+       /* drop payload output stream from previous attempt */
+       if (req->payload_output != NULL)
+               o_stream_unref(&req->payload_output);
+
        newport = (url->have_port ? url->port : (url->have_ssl ? 443 : 80));
        target = http_url_create_target(url);
 
@@ -663,6 +668,10 @@ void http_client_request_resubmit(struct http_client_request *req)
                }
        }
 
+       /* drop payload output stream from previous attempt */
+       if (req->payload_output != NULL)
+               o_stream_unref(&req->payload_output);
+
        req->conn = NULL;
        req->peer = NULL;
        req->state = HTTP_REQUEST_STATE_QUEUED;