]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] config: don't crash on empty pattern files.
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Mar 2011 06:27:02 +0000 (07:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Mar 2011 09:22:30 +0000 (10:22 +0100)
Both Hank A. Paulson and Rob at pixsense reported a crash when
loading ACLs from a pattern file which contains empty lines.

From the tests, it appears that only files that contain nothing
but empty lines are causing that (in the past they would have had
their line feeds loaded as patterns).

The crash happens in the free_pattern() call which doesn't like to
be called with a NULL pattern. Let's make it accept it so that it's
more in line with the standard uses of free() which ignores NULLs.

src/acl.c

index fcfbf9fc2e559e41454e6d3fd4bf94a0879f577e..26b82cb35d710e6441195b51ea5bd2e3a7b70fa3 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1008,8 +1008,11 @@ struct acl_keyword *find_acl_kw(const char *kw)
        return NULL;
 }
 
+/* NB: does nothing if <pat> is NULL */
 static void free_pattern(struct acl_pattern *pat)
 {
+       if (!pat)
+               return;
 
        if (pat->ptr.ptr) {
                if (pat->freeptrbuf)