]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-htx: Handle warnings when parsing http-error and http-errors
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Nov 2020 09:58:01 +0000 (10:58 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Nov 2020 15:26:10 +0000 (16:26 +0100)
First of all, this patch is tagged as a bug. But in fact, it only fixes a bug in
the 2.2. On the 2.3 and above, it only add the ability to display warnings, when
an http-error directive is parsed from a proxy section and when an errorfile
directive is parsed from a http-errors section.

But on the 2.2, it make sure to display the warning emitted on a content-length
mismatch when an errorfile is parsed. The following is only applicable to the
2.2.

commit "BUG/MINOR: http-htx: Just warn if payload of an errorfile doesn't match
the C-L" (which is only present in 2.2, 2.1 and 2.0 trees, i.e see commit
7bf3d81d3cf4b9f4587 in 2.2 tree), is changing the behavior of `http_str_to_htx`
function. It may now emit warnings. And, it is the caller responsibility to
display it.

But the warning is missing when an 'http-error' directive is parsed from
a proxy section. It is also missing when an 'errorfile' directive is
parsed from a http-errors section.

This bug only exists on the 2.2. On earlier versions, these directives
are not supported and on later ones, an error is triggered instead of a
warning.

Thanks to William Dauchy that spotted the bug.

This patch must be backported as far as 2.2.

src/http_htx.c

index 22bba1a4eca59182d3548ac6a48c36ed0e937a6d..d3c3f42a4655882cdd12fda48bfdf9d4c8d72c8d 100644 (file)
@@ -1987,6 +1987,9 @@ static int proxy_parse_http_error(char **args, int section, struct proxy *curpx,
        conf_err->line = line;
        LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
 
+       /* handle warning message */
+       if (*errmsg)
+               ret = 1;
   out:
        return ret;
 
@@ -2200,6 +2203,10 @@ static int cfg_parse_http_errors(const char *file, int linenum, char **args, int
                        err_code |= ERR_ALERT | ERR_FATAL;
                        goto out;
                }
+               if (errmsg) {
+                       ha_warning("parsing [%s:%d] : %s: %s\n", file, linenum, args[0], errmsg);
+                       err_code |= ERR_WARN;
+               }
 
                reply = calloc(1, sizeof(*reply));
                if (!reply) {