]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: acl: proprely release unused args in prune_acl_expr()
authorWilly Tarreau <w@1wt.eu>
Wed, 19 Apr 2017 09:13:48 +0000 (11:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 19 Apr 2017 09:31:44 +0000 (11:31 +0200)
Stephan Zeisberg reported another dirty abort case which can be triggered
with this simple config (where file "d" doesn't exist) :

    backend b1
        stats  auth a:b
        acl auth_ok http_auth(c) -f d

This issue was brought in 1.5-dev9 by commit 34db108 ("MAJOR: acl: make use
of the new argument parsing framework") when prune_acl_expr() started to
release arguments. The arg pointer is set to NULL but not its length.
Because of this, later in smp_resolve_args(), the argument is still seen
as valid (since only a test on the length is made as in all other places),
and the NULL pointer is dereferenced.

This patch properly clears the lengths to avoid such tests.

This fix needs to be backported to 1.7, 1.6, and 1.5.

src/acl.c

index 93d365851b034dbdbc24ecb61739187ebf2b604e..da62e6c01b6b0d62da04e2ad2a033fd0bac342df 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -115,6 +115,7 @@ static struct acl_expr *prune_acl_expr(struct acl_expr *expr)
                if (arg->type == ARGT_STR || arg->unresolved) {
                        free(arg->data.str.str);
                        arg->data.str.str = NULL;
+                       arg->data.str.len = 0;
                        unresolved |= arg->unresolved;
                        arg->unresolved = 0;
                }