From: Willy Tarreau Date: Thu, 6 May 2021 05:52:50 +0000 (+0200) Subject: BUG/MINOR: config: .if/.elif should also accept negative integers X-Git-Tag: v2.4-dev19~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71990e6becb0d448915e453e4ce17dde67b8563b;p=thirdparty%2Fhaproxy.git BUG/MINOR: config: .if/.elif should also accept negative integers The doc about .if/.elif config block conditions says: a non-nul integer (e.g. '1'), always returns "true" So we must accept negative integers as well. The test was made on atoi() > 0. No backport is needed, this is only 2.4. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index b6145fc8a5..0048a12cbb 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1865,7 +1865,7 @@ next_line: } else if (!*args[1] || *args[1] == '0') { /* empty = false */ nested_conds[nested_cond_lvl] = NESTED_COND_IF_DROP; - } else if (atoi(args[1]) > 0) { + } else if (atoi(args[1]) != 0) { /* true */ nested_conds[nested_cond_lvl] = NESTED_COND_IF_TAKE; } else { @@ -1897,7 +1897,7 @@ next_line: } else if (!*args[1] || *args[1] == '0') { /* empty = false */ nested_conds[nested_cond_lvl] = NESTED_COND_ELIF_DROP; - } else if (atoi(args[1]) > 0) { + } else if (atoi(args[1]) != 0) { /* true */ nested_conds[nested_cond_lvl] = NESTED_COND_ELIF_TAKE; } else {