]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-htx: Do case-insensive comparisons on Host header name
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2020 08:47:07 +0000 (09:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2020 09:49:09 +0000 (10:49 +0100)
When a header is added or modified, in http_add_header() or
http_replace_header(), a comparison is performed on its name to know if it is
the Host header and if the authority part of the uri must be updated or
not. This comparision must be case-insensive.

This patch should fix the issue #522. It must be backported to 2.1.

src/http_act.c
src/http_htx.c

index c4a7ad4a7bf942fe9745ff9d006dd8e7bacfa7e0..9bfa7ebe44b6d4f582c5232b8e69e8609ad92484 100644 (file)
@@ -1398,7 +1398,6 @@ static enum act_parse_ret parse_http_del_header(const char **args, int *orig_arg
 
        rule->arg.http.str.ptr = strdup(args[cur_arg]);
        rule->arg.http.str.len = strlen(rule->arg.http.str.ptr);
-
        px->conf.args.ctx = (rule->from == ACT_F_HTTP_REQ ? ARGC_HRQ : ARGC_HRS);
 
        LIST_INIT(&rule->arg.http.fmt);
index d5239671b0363720547ac31d9ca12f93652ad9d6..35bb056252e2b8bd7a246529f2a44ecda78e25e7 100644 (file)
@@ -215,7 +215,7 @@ int http_add_header(struct htx *htx, const struct ist n, const struct ist v)
 
   end:
        sl = http_get_stline(htx);
-       if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteq(n, ist("host"))) {
+       if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteqi(n, ist("host"))) {
                if (!http_update_authority(htx, sl, v))
                        goto fail;
        }
@@ -491,7 +491,7 @@ int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx,
                goto fail;
 
        sl = http_get_stline(htx);
-       if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteq(name, ist("host"))) {
+       if (sl && (sl->flags & HTX_SL_F_HAS_AUTHORITY) && isteqi(name, ist("host"))) {
                if (!http_update_authority(htx, sl, value))
                        goto fail;
                ctx->blk = NULL;