]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] config: fix wrong handling of too large argument count
authorWilly Tarreau <w@1wt.eu>
Mon, 9 Nov 2009 20:16:53 +0000 (21:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 6 Dec 2009 12:23:43 +0000 (13:23 +0100)
Holger Just reported that running ACLs with too many args caused
a segfault during config parsing. This is caused by a wrong test
on argument count. In case of too many arguments on a config line,
the last one was not correctly zeroed. This is now done and we
report the error indicating what part had been truncated.
(cherry picked from commit 3b39c1446b9bd842324e87782a836948a07c25a2)

src/cfgparse.c

index eb7db0f9cbd92cabe07db6f94d46098194504975..91a20bdf1dde67fcfd878187ca2b7edba7c4ebad 100644 (file)
@@ -3996,6 +3996,21 @@ int readcfgfile(const char *file)
                if (!**args)
                        continue;
 
+               if (*line) {
+                       /* we had to stop due to too many args.
+                        * Let's terminate the string, print the offending part then cut the
+                        * last arg.
+                        */
+                       while (*line && *line != '#' && *line != '\n' && *line != '\r')
+                               line++;
+                       *line = '\0';
+
+                       Alert("parsing [%s:%d]: line too long, truncating at word %d, position %d : <%s>.\n",
+                             file, linenum, arg + 1, args[arg] - thisline + 1, args[arg]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       args[arg] = line;
+               }
+
                /* zero out remaining args and ensure that at least one entry
                 * is zeroed out.
                 */