]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: tcpcheck: Don't eval custom expect rule on an empty buffer
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Apr 2023 12:47:15 +0000 (14:47 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Apr 2023 13:01:10 +0000 (15:01 +0200)
The commit a664aa6a6 ("BUG/MINOR: tcpcheck: Be able to expect an empty
response") instroduced a regression for expect rules relying on a custom
function. Indeed, there is no check on the buffer to be sure it is not empty
before calling the custom function. But some of these functions expect to
have data and don't perform any test on the buffer emptiness.

So instead of fixing all custom functions, we just don't eval them if the
buffer is empty.

This patch must be backported but only if the commit above was backported
first.

src/tcpcheck.c

index 55fd190cf263f80121a2f65ac9f4f7bd9346db47..117be327513f19935600f452c4aa18616c4efcff 100644 (file)
@@ -2047,6 +2047,13 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect(struct check *check, struct tcpcheck
                break;
 
        case TCPCHK_EXPECT_CUSTOM:
+               /* Don't eval custom function if the buffer is empty. It means
+                * cusstom functions can't expect an empty response. If this
+                * change, don't forget to change this test and update all
+                * custom functions.
+                */
+               if (!b_data(&check->bi))
+                       break;
                if (expect->custom)
                        ret = expect->custom(check, rule, last_read);
                goto out;