From: Willy Tarreau Date: Tue, 13 May 2014 15:57:29 +0000 (+0200) Subject: BUG/MINOR: checks: tcp-check must not stop on '\0' for binary checks X-Git-Tag: v1.5-dev26~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec6b012bf4e4157c14e474db0a85e80f7e618b94;p=thirdparty%2Fhaproxy.git BUG/MINOR: checks: tcp-check must not stop on '\0' for binary checks Abuse of copy-paste has made "tcp-check expect binary" to consider a buffer starting with \0 as empty! Thanks to Lukas Benes for reporting this problem and confirming the fix. This is 1.5-only, no backport is needed. --- diff --git a/src/checks.c b/src/checks.c index 5eb5a76c84..b94ff6263c 100644 --- a/src/checks.c +++ b/src/checks.c @@ -1975,7 +1975,6 @@ static int tcpcheck_get_step_id(struct server *s) static void tcpcheck_main(struct connection *conn) { char *contentptr; - unsigned int contentlen; struct list *head = NULL; struct tcpcheck_rule *cur = NULL; int done = 0, ret = 0; @@ -2253,10 +2252,9 @@ static void tcpcheck_main(struct connection *conn) } contentptr = check->bi->data; - contentlen = check->bi->i; /* Check that response body is not empty... */ - if (*contentptr == '\0') { + if (!check->bi->i) { if (!done) continue; @@ -2273,7 +2271,7 @@ static void tcpcheck_main(struct connection *conn) tcpcheck_expect: if (cur->string != NULL) - ret = my_memmem(contentptr, contentlen, cur->string, cur->string_len) != NULL; + ret = my_memmem(contentptr, check->bi->i, cur->string, cur->string_len) != NULL; else if (cur->expect_regex != NULL) ret = regexec(cur->expect_regex, contentptr, MAX_MATCH, pmatch, 0) == 0;