]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: fcgi-app: fix memory leak in fcgi_flt_http_headers
authorHarris Kaufmann <st4ck0v3rfl0w@gmail.com>
Wed, 15 Jul 2020 14:26:13 +0000 (16:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 15 Jul 2020 18:23:29 +0000 (20:23 +0200)
When the loop is continued early, the memory for param_rule is not freed. This
can leak memory per request, which will eventually consume all available memory
on the server.

This patch should fix the issue #750. It must be backported as far as 2.1.

src/fcgi-app.c

index d7285bfa6bbfc372f670f5125525036854ba8272..412584c660f099e530a7fdec5bec7b9578cccc85 100644 (file)
@@ -448,8 +448,10 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct
 
                b_reset(value);
                value->data = build_logline(s, value->area, value->size, param_rule->value);
-               if (!value->data)
+               if (!value->data) {
+                       pool_free(pool_head_fcgi_param_rule, param_rule);
                        continue;
+               }
                if (!http_add_header(htx, param_rule->name, ist2(value->area, value->data)))
                        goto rewrite_err;
                pool_free(pool_head_fcgi_param_rule, param_rule);