From: Willy Tarreau Date: Tue, 28 Feb 2017 08:34:39 +0000 (+0100) Subject: BUG/MEDIUM: config: reject anything but "if" or "unless" after a use-backend rule X-Git-Tag: v1.8-dev1~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f86264bae1e8bec4bf0f0596975597f6fec48ef;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: config: reject anything but "if" or "unless" after a use-backend rule 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. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index bafd05133d..54869608da 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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) {