]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Memory leak of http redirect rules' format string
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 6 Jan 2023 15:31:06 +0000 (16:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Jan 2023 15:42:24 +0000 (16:42 +0100)
When the configuration contains such a line:
    http-request redirect location /
a "struct logformat_node" object is created and it contains an "arg"
member which gets alloc'ed as well in which we copy the new location
(see add_to_logformat_list). This internal arg pointer was not freed in
the dedicated release_http_redir release function.
Likewise, the expression pointer was not released as well.

This patch can be backported to all stable branches. It should apply
as-is all the way to 2.2 but it won't on 2.0 because release_http_redir
did not exist yet.

src/http_act.c
src/proxy.c

index 5582085d48bc6944f6c17a8d429236fac83480e5..fb77f801b210e204b7a0343c7b06eda293afceba 100644 (file)
@@ -1769,6 +1769,8 @@ static void release_http_redir(struct act_rule *rule)
        free(redir->cookie_str);
        list_for_each_entry_safe(lf, lfb, &redir->rdr_fmt, list) {
                LIST_DELETE(&lf->list);
+               release_sample_expr(lf->expr);
+               free(lf->arg);
                free(lf);
        }
        free(redir);
index 8bcc98c0d92c5dc20fbb132d25e062c91c569bb3..e53cc4f72d49f08f3fb062f7da43f3f5c249ca48 100644 (file)
@@ -244,6 +244,8 @@ void free_proxy(struct proxy *p)
                free(rdr->rdr_str);
                list_for_each_entry_safe(lf, lfb, &rdr->rdr_fmt, list) {
                        LIST_DELETE(&lf->list);
+                       release_sample_expr(lf->expr);
+                       free(lf->arg);
                        free(lf);
                }
                free(rdr);