From: Maciej Zdeb Date: Fri, 20 Nov 2020 12:12:24 +0000 (+0000) Subject: BUG/MINOR: http_htx: Fix searching headers by substring X-Git-Tag: v2.3.2~19 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=f77465cb8e22a3793141df63ee28af670316930d;p=haproxy-2.3.git BUG/MINOR: http_htx: Fix searching headers by substring Function __http_find_header is used to search headers by name using specified matching method. Matching by substring returned unexpected results due to wrong length of substring supplied to strnistr function. Fixed also the boolean condition by inverting it, as we're interested in headers that contains the substring. This patch should be backported as far as 2.2 (cherry picked from commit 302b9f8d7a3805bfd25ecf267a8ddd730c6887b3) Signed-off-by: Christopher Faulet --- diff --git a/src/http_htx.c b/src/http_htx.c index d3c3f42..63e9dc2 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -201,7 +201,7 @@ static int __http_find_header(const struct htx *htx, const void *pattern, struct goto next_blk; break; case HTTP_FIND_FL_MATCH_SUB: - if (strnistr(n.ptr, n.len, name.ptr, n.len) != NULL) + if (!strnistr(n.ptr, n.len, name.ptr, name.len)) goto next_blk; break; default: