]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: Make matching on HTTP headers for expect rules less obscure
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 May 2020 13:41:39 +0000 (15:41 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 May 2020 13:41:41 +0000 (15:41 +0200)
A default statement in the switch testing the header name has been added to be
sure it is impossible to eval the value pattern on an uninitialized header
value. It should never happen of course. But this way, it is explicit.

And a comment has been added to make clear that ctx.value is always defined when
it is evaluated.

This patch fixes the issue #619.

src/checks.c

index b59c6b7e979d1d48ff77a82d21109a57e6107036..bb78cc845f1e40b78853c298a32edb0dd5acaf6a 100644 (file)
@@ -2296,8 +2296,16 @@ static enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, str
                                if (!http_match_header(htx, expect->hdr.name_re, &ctx, full))
                                        goto end_of_match;
                                break;
+                       default:
+                               /* should never happen */
+                               goto end_of_match;
                        }
 
+                       /* A header has matched the name pattern, let's test its
+                        * value now (always defined from there). If there is no
+                        * value pattern, it is a good match.
+                        */
+
                        if (expect->flags & TCPCHK_EXPT_FL_HTTP_HVAL_NONE) {
                                match = 1;
                                goto end_of_match;