send_http_request(): Prevent memory leaks when handling errors
authorJoshua Rogers <jrogers@opera.com>
Fri, 19 Nov 2021 17:57:26 +0000 (18:57 +0100)
committerFabian Keil <fk@fabiankeil.de>
Tue, 7 Dec 2021 14:06:06 +0000 (15:06 +0100)
OVE-20211201-0001. CVE-2021-44542.

jcc.c

diff --git a/jcc.c b/jcc.c
index 659521c..2d6ba77 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -2206,6 +2206,7 @@ static int send_http_request(struct client_state *csp)
          update_client_headers(csp, to_send_len))
       {
          log_error(LOG_LEVEL_HEADER, "Error updating client headers");
+         freez(to_send);
          return 1;
       }
       csp->expected_client_content_length = 0;
@@ -2230,6 +2231,10 @@ static int send_http_request(struct client_state *csp)
    {
       log_error(LOG_LEVEL_CONNECT, "Failed sending request headers to: %s: %E",
          csp->http->hostport);
+      if (filter_client_body)
+      {
+         freez(to_send);
+      }
       return 1;
    }