]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http/htx: use conn_get_dst() to retrieve the destination address
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Jul 2019 09:49:08 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jul 2019 11:50:09 +0000 (13:50 +0200)
When adding the X-Original-To header, let's use conn_get_dst() and make
sure it succeeds, since  previous call to conn_get_to_addr() was unchecked.

src/http_ana.c

index ac3412bf005246204cd5e699de29027988965317..20091809941f9d02cac16e87bb0ebad8d39b4b11 100644 (file)
@@ -864,12 +864,10 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
        if ((sess->fe->options | s->be->options) & PR_O_ORGTO) {
 
                /* FIXME: don't know if IPv6 can handle that case too. */
-               if (cli_conn && cli_conn->addr.from.ss_family == AF_INET) {
+               if (cli_conn && cli_conn->addr.from.ss_family == AF_INET && conn_get_dst(cli_conn)) {
                        /* Add an X-Original-To header unless the destination IP is
                         * in the 'except' network range.
                         */
-                       conn_get_to_addr(cli_conn);
-
                        if (cli_conn->addr.to.ss_family == AF_INET &&
                            ((!sess->fe->except_mask_to.s_addr ||
                              (((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & sess->fe->except_mask_to.s_addr)