]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] acl: fix handling of empty lines in pattern files
authorWilly Tarreau <w@1wt.eu>
Mon, 3 Jan 2011 20:04:10 +0000 (21:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Jan 2011 20:06:32 +0000 (21:06 +0100)
Gabriel Sosa reported that haproxy unexpectedly reports an error
when a pattern file loaded by an ACL contains an empty line. The
test was present but inefficient as it did not consider the '\n'
as the end of the line. This fix relies on the line length instead.

It should be backported to 1.4.

src/acl.c

index be28ca9e706f96d428d87b7e8539a111ea46d096..c8a5a8860331004cf696d3f87b44a5c2d0bf26f7 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1083,15 +1083,16 @@ static int acl_read_patterns_from_file( struct acl_keyword *aclkw,
                while (*c == ' ' || *c == '\t')
                        c++;
 
-               /* empty lines are ignored too */
-               if (!*c)
-                       continue;
 
                args[0] = c;
                while (*c && *c != '\n' && *c != '\r')
                        c++;
                *c = 0;
 
+               /* empty lines are ignored too */
+               if (c == args[0])
+                       continue;
+
                /* we keep the previous pattern along iterations as long as it's not used */
                if (!pattern)
                        pattern = (struct acl_pattern *)malloc(sizeof(*pattern));