]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Apr 2020 05:19:04 +0000 (07:19 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 27 Apr 2020 08:46:28 +0000 (10:46 +0200)
When default parameters are set in a request message, we get the client
connection using the session's origin. But it is not necessarily a
conncection. For instance, for health checks, thanks to recent changes, it may
be a check object. At this step, the client connection may be NULL. Thus, we
must be sure to have a client connection before using it.

This patch must be backported to 2.1.

src/mux_fcgi.c

index 63be2d6587a447e2752b3bcc84b53e8912bccfc9..cef3074a3c287d1651ff0a26b68a26b1a7f3ac44 100644 (file)
@@ -1225,7 +1225,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_SRV_PORT)) {
                char *end;
                int port = 0;
-               if (conn_get_dst(cli_conn))
+               if (cli_conn && conn_get_dst(cli_conn))
                        port = get_host_port(cli_conn->dst);
                end = ultoa_o(port, b_tail(params->p), b_room(params->p));
                if (!end)
@@ -1239,7 +1239,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
                if (!istlen(params->srv_name)) {
                        char *ptr = NULL;
 
-                       if (conn_get_dst(cli_conn))
+                       if (cli_conn && conn_get_dst(cli_conn))
                                if (addr_to_str(cli_conn->dst, b_tail(params->p), b_room(params->p)) != -1)
                                        ptr = b_tail(params->p);
                        if (ptr) {
@@ -1251,7 +1251,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_REM_ADDR)) {
                char *ptr = NULL;
 
-               if (conn_get_src(cli_conn))
+               if (cli_conn && conn_get_src(cli_conn))
                        if (addr_to_str(cli_conn->src, b_tail(params->p), b_room(params->p)) != -1)
                                ptr = b_tail(params->p);
                if (ptr) {
@@ -1262,7 +1262,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        if (!(params->mask & FCGI_SP_REM_PORT)) {
                char *end;
                int port = 0;
-               if (conn_get_src(cli_conn))
+               if (cli_conn && conn_get_src(cli_conn))
                        port = get_host_port(cli_conn->src);
                end = ultoa_o(port, b_tail(params->p), b_room(params->p));
                if (!end)
@@ -1292,7 +1292,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
        }
 #ifdef USE_OPENSSL
        if (!(params->mask & FCGI_SP_HTTPS)) {
-               params->https = ssl_sock_is_ssl(cli_conn);
+               if (cli_conn)
+                       params->https = ssl_sock_is_ssl(cli_conn);
        }
 #endif
        if ((params->mask & FCGI_SP_URI_MASK) != FCGI_SP_URI_MASK) {