]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: fix uninitialized initial state in ".if" block evaluator
authorWilly Tarreau <w@1wt.eu>
Thu, 6 May 2021 06:46:11 +0000 (08:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 May 2021 08:35:03 +0000 (10:35 +0200)
The condition to skip the block in the ".if" evaluator forgot to check
that the level was high enough, resulting in rare cases where a random
value matched one of the 5 values that cause the block to be skipped.

No backport is needed as it's 2.4-only.

src/cfgparse.c

index 59d0e912bc6016b9705a3555ca969ba0d8450fab..13362214c0382dafbf2593ed3265670ba752497d 100644 (file)
@@ -1855,11 +1855,12 @@ next_line:
                                        goto err;
                                }
 
-                               if (nested_conds[nested_cond_lvl - 1] == NESTED_COND_IF_DROP ||
-                                   nested_conds[nested_cond_lvl - 1] == NESTED_COND_IF_SKIP ||
-                                   nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELIF_DROP ||
-                                   nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELIF_SKIP ||
-                                   nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELSE_DROP) {
+                               if (nested_cond_lvl > 1 &&
+                                   (nested_conds[nested_cond_lvl - 1] == NESTED_COND_IF_DROP ||
+                                    nested_conds[nested_cond_lvl - 1] == NESTED_COND_IF_SKIP ||
+                                    nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELIF_DROP ||
+                                    nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELIF_SKIP ||
+                                    nested_conds[nested_cond_lvl - 1] == NESTED_COND_ELSE_DROP)) {
                                        nested_conds[nested_cond_lvl] = NESTED_COND_IF_SKIP;
                                } else if (!*args[1] || *args[1] == '0') {
                                        /* empty = false */