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)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 10:19:54 +0000 (12:19 +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.

(cherry picked from commit bb86a0f7be6ba8a248321a59c4b865e01e33f106)
Signed-off-by: Willy Tarreau <w@1wt.eu>

src/mux_fcgi.c

index dd7200b..e3349c5 100644 (file)
@@ -1242,7 +1242,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)
@@ -1256,7 +1256,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) {
@@ -1268,7 +1268,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) {
@@ -1279,7 +1279,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)
@@ -1309,7 +1309,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) {