]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: config: reject anything but "if" or "unless" after a use-backend rule
authorWilly Tarreau <w@1wt.eu>
Tue, 28 Feb 2017 08:34:39 +0000 (09:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 Feb 2017 08:34:39 +0000 (09:34 +0100)
Adrian Fitzpatrick reported that since commit f51658d ("MEDIUM: config:
relax use_backend check to make the condition optional"), typos like "of"
instead of "if" on use_backend rules are not properly detected. The reason
is that the parser only checks for "if" or "unless" otherwise it considers
there's no keyword, making the rule inconditional.

This patch fixes it. It may reveal some rare config bugs for some people,
but will not affect valid configurations.

This fix must be backported to 1.7, 1.6 and 1.5.

src/cfgparse.c

index bafd05133d4c21f9c1c0566ea6aa38fc6f69568d..54869608da034fad8bab65e1715a6875039b9ba6 100644 (file)
@@ -3776,6 +3776,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
 
                        err_code |= warnif_cond_conflicts(cond, SMP_VAL_FE_SET_BCK, file, linenum);
                }
+               else if (*args[2]) {
+                       Alert("parsing [%s:%d] : unexpected keyword '%s' after switching rule, only 'if' and 'unless' are allowed.\n",
+                             file, linenum, args[2]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
 
                rule = calloc(1, sizeof(*rule));
                if (!rule) {