]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: http-request replace-path duplicates the query string
authorJerome Magnin <jmagnin@haproxy.com>
Fri, 21 Feb 2020 09:37:48 +0000 (10:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 10:52:14 +0000 (11:52 +0100)
In http_action_replace_uri() we call http_get_path() in the case of
a replace-path rule. http_get_path() will return an ist pointing to
the start of the path, but uri.ptr + uri.len points to the end of the
uri. As as result, we are matching against a string containing the
query, which we append to the "path" later, effectively duplicating
the query string.

This patch uses the iststop() function introduced in "MINOR: ist: add
an iststop() function" to find the '?' character and update the ist
length when needed.

This fixes issue #510.

The bug was introduced by commit 262c3f1a ("MINOR: http: add a new
"replace-path" action"), which was backported to 2.1 and 2.0.

src/http_act.c

index 718501416589726f18689398f25350f7f485318a..c4a7ad4a7bf942fe9745ff9d006dd8e7bacfa7e0 100644 (file)
@@ -202,7 +202,7 @@ static enum act_return http_action_replace_uri(struct act_rule *rule, struct pro
        uri = htx_sl_req_uri(http_get_stline(htxbuf(&s->req.buf)));
 
        if (rule->action == 1) // replace-path
-               uri = http_get_path(uri);
+               uri = iststop(http_get_path(uri), '?');
 
        if (!regex_exec_match2(rule->arg.http.re, uri.ptr, uri.len, MAX_MATCH, pmatch, 0))
                goto leave;