]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http: Return an error in proxy mode when url2sa fails
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Apr 2018 13:53:12 +0000 (15:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Apr 2018 13:31:18 +0000 (15:31 +0200)
In proxy mode, the result of url2sa is never checked. So when the function fails
to resolve the destination server from the URL, we continue. Depending on the
internal state of the connection, we get different behaviours. With a newly
allocated connection, the field <addr.to> is not set. So we will get a HTTP
error. The status code is 503 instead of 400, but it's not really critical. But,
if it's a recycled connection, we will reuse the previous value of <addr.to>,
opening a connection on an unexpected server.

To fix the bug, we return an error when url2sa fails.

This patch should be backported in all version from 1.5.

src/proto_http.c

index 80e001d694eb9139a9f772f17ef070777370908e..8370889b417c798496c8f48fa5ab5a5aaf73ee0d 100644 (file)
@@ -3720,9 +3720,11 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
                }
 
                path = http_get_path(txn);
-               url2sa(req->buf->p + msg->sl.rq.u,
-                      path ? path - (req->buf->p + msg->sl.rq.u) : msg->sl.rq.u_l,
-                      &conn->addr.to, NULL);
+               if (url2sa(req->buf->p + msg->sl.rq.u,
+                          path ? path - (req->buf->p + msg->sl.rq.u) : msg->sl.rq.u_l,
+                          &conn->addr.to, NULL) == -1)
+                       goto return_bad_req;
+
                /* if the path was found, we have to remove everything between
                 * req->buf->p + msg->sl.rq.u and path (excluded). If it was not
                 * found, we need to replace from req->buf->p + msg->sl.rq.u for