]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] ensure that we always have a null word in config
authorWilly Tarreau <w@1wt.eu>
Wed, 2 May 2007 18:50:16 +0000 (20:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2007 12:12:06 +0000 (14:12 +0200)
It is important when parsing configuration file to ensure that at
least one word is empty to mark the end of the line. This will be
required with ACLs in order to avoid reading past the end of line.

src/cfgparse.c

index feb7b6064c19f647f9601c008d32bc5f8b2f73de..c5d17440f5ed98de76e2791eab52cd7450b300f4 100644 (file)
@@ -2052,7 +2052,7 @@ int readcfgfile(const char *file)
        FILE *f;
        int linenum = 0;
        char *end;
-       char *args[MAX_LINE_ARGS];
+       char *args[MAX_LINE_ARGS + 1];
        int arg;
        int cfgerr = 0;
        int nbchk, mininter;
@@ -2142,8 +2142,10 @@ int readcfgfile(const char *file)
                if (!**args)
                        continue;
 
-               /* zero out remaining args */
-               while (++arg < MAX_LINE_ARGS) {
+               /* zero out remaining args and ensure that at least one entry
+                * is zeroed out.
+                */
+               while (++arg <= MAX_LINE_ARGS) {
                        args[arg] = line;
                }