Hank, Rob,

I could reproduce the segfault when loading files composed only of
empty lines. Now they're really containing zero pattern, while in
the past, the line feeds would have been loaded as patterns. Please
test the attached patch and confirm it fixes the issue for you, and
I will release 1.4.13 with only that fix in it.

Thanks very much for your report!
Willy

commit e0b8d0e6c1352b80b5a0765d750e2748a7fe8af4
Author: Willy Tarreau <[email protected]>
Date:   Wed Mar 9 07:27:02 2011 +0100

    [BUG] config: don't crash on empty pattern files.
    
    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.
    (cherry picked from commit 37724621d64d2b506d774c469b767dad30585422)

diff --git a/src/acl.c b/src/acl.c
index 14831dd..9571bb2 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -709,8 +709,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)

Reply via email to