]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proxy: fix logformat expression leak in use_backend rules
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 13 Mar 2024 15:29:38 +0000 (16:29 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 4 Apr 2024 17:10:01 +0000 (19:10 +0200)
When support for dynamic names was added for use_backend rules in
702d44f2f ("MEDIUM: proxy: support use_backend with dynamic names"), the
sample expression resulting from parse_logformat_string() was only freed
for non dynamic rules (when the expression resolved to a simple string
node). But for complex expressions (ie: multiple nodes), rule->dynamic
was set but the expression was never released, resulting in a small
memory leak when freeing the parent proxy.

To fix the issue, in free_proxy(), we free the switching rule expression
if the switching rule is dynamic.

This should be backported to every stable versions.
[ada: prior to 2.9, free_logformat_list() helper did not exist: we may
 use the same manual sample expr freeing logic as in server_rules pruning
 right above it]

src/proxy.c

index ac446d3b5e0635e635c3693d51bed2fb282fb224..c56007acf1fc7d3df5b5db9a2fbe2dea91bd67db 100644 (file)
@@ -263,6 +263,8 @@ void free_proxy(struct proxy *p)
        list_for_each_entry_safe(rule, ruleb, &p->switching_rules, list) {
                LIST_DELETE(&rule->list);
                free_acl_cond(rule->cond);
+               if (rule->dynamic)
+                       free_logformat_list(&rule->be.expr);
                free(rule->file);
                free(rule);
        }