Re: httpd: do NOT send location fcgiparams twice

Kirill A. Korinsky <[email protected]> Fri, 17 Jul 2026 15:16:52 +0200
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
On Mon, 13 Jul 2026 21:44:51 +0200,
Rafael Sadowski <[email protected]> wrote:
> 
> 
> OK?
>

I do not use fastcgi but it reads sane, so OK kirill@

> commit 87c270a68ae2c43d388a2c65f08c83e73a0d905d
> Author: Rafael Sadowski <[email protected]>
> Date:   Mon Jul 13 13:33:34 2026 +0200
> 
>     httpd: send TLS and fcgiparams config once per server
>     
>     Both calls target the server child but were made inside the loop
>     over all config receivers, so the server child received the FCGI
>     params twice per location and the backends saw every param
>     duplicated.  Move them after the loop and check the return values.
>     
>     idea suggested by Fabien Romano
> 
> diff --git a/config.c b/config.c
> index 146ed2c..c2062a3 100644
> --- a/config.c
> +++ b/config.c
> @@ -268,9 +268,6 @@ config_setserver(struct httpd *env, struct server *srv)
>  					return (-1);
>  				}
>  			}
> -
> -			/* Configure TLS if necessary. */
> -			config_setserver_tls(env, srv);
>  		} else {
>  			if (proc_composev(ps, id, IMSG_CFG_SERVER,
>  			    iov, c) != 0) {
> @@ -279,12 +276,19 @@ config_setserver(struct httpd *env, struct server *srv)
>  				    __func__, srv->srv_conf.name);
>  				return (-1);
>  			}
> -
> -			/* Configure FCGI parameters if necessary. */
> -			config_setserver_fcgiparams(env, srv);
>  		}
>  	}
>  
> +	if ((srv->srv_conf.flags & SRVFLAG_LOCATION) == 0) {
> +		/* Configure TLS if necessary. */
> +		if (config_setserver_tls(env, srv) != 0)
> +			return (-1);
> +	}
> +
> +	/* Configure FCGI parameters if necessary. */
> +	if (config_setserver_fcgiparams(env, srv) != 0)
> +		return (-1);
> +
>  	/* Close server socket early to prevent fd exhaustion in the parent. */
>  	if (srv->srv_s != -1) {
>  		close(srv->srv_s);
> 

-- 
wbr, Kirill