From cc4f88bdb643d9b6f94a6820fec77f6aba6e7ae1 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 24 Apr 2020 07:19:04 +0200 Subject: [PATCH] BUG/MINOR: mux-fcgi: Be sure to have a connection as session's origin to use it 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 --- src/mux_fcgi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index dd7200b..e3349c5 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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) { -- 1.7.10.4