From: Christopher Faulet Date: Wed, 7 Oct 2026 14:05:00 +0000 (+0200) Subject: BUG/MINOR: mux-h1: convert the argument of h1-case-adjust to lower case X-Git-Tag: v3.5-dev10~136 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=30dd1c05f5d73f4d9f753b3e6f93208a9260d1d1;p=haproxy.git BUG/MINOR: mux-h1: convert the argument of h1-case-adjust to lower case The "h1-case-adjust" global directive (and the file loaded with "h1-case-adjust-file") takes the header name to match in lower case, as specified in the documentation, but it was not checked. So with: h1-case-adjust X-Up X-Up the rule was accepted without any warning but never matched since header names are looked up in lower case, and "x-up" was still emitted. Let's convert to lower case before inserting it in the map, which also makes duplicate detection work regardless of the case. It could be backported to all supported versions. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 0a6d29e80..093a749f9 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -5847,6 +5847,7 @@ static int h1_show_sd(struct buffer *msg, struct sedesc *sd, const char *pfx) static int add_hdr_case_adjust(const char *from, const char *to, char **err) { struct h1_hdr_entry *entry; + char *key, *p; /* Be sure there is a non-empty */ if (!strlen(to)) { @@ -5860,24 +5861,36 @@ static int add_hdr_case_adjust(const char *from, const char *to, char **err) return -1; } + /* is looked up using lower case header names, so it is + * converted to lower case. + */ + key = strdup(from); + if (!key) { + memprintf(err, "out of memory"); + return -1; + } + for (p = key; *p; p++) + *p = tolower((unsigned char)*p); + /* Be sure does not already existsin the tree */ - if (ebis_lookup(&hdrs_map.map, from)) { + if (ebis_lookup(&hdrs_map.map, key)) { memprintf(err, "duplicate entry '%s'", from); + free(key); return -1; } /* Create the entry and insert it in the tree */ entry = malloc(sizeof(*entry)); if (!entry) { + free(key); memprintf(err, "out of memory"); return -1; } - entry->node.key = strdup(from); + entry->node.key = key; entry->name = ist(strdup(to)); - if (!entry->node.key || !isttest(entry->name)) { + if (!isttest(entry->name)) { free(entry->node.key); - istfree(&entry->name); free(entry); memprintf(err, "out of memory"); return -1;