]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: Duplicate healthcheck's sni inherited from default server
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 1 Sep 2025 13:13:07 +0000 (15:13 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 1 Sep 2025 13:45:05 +0000 (15:45 +0200)
It is not really an issue, but the "check-sni" value inerited from a default
server is not duplicated while the paramter value is duplicated during the
parsing. So here there is a small leak if several "check-sni" parameters are
used on the same server line. The previous value is never released. But to
fix this issue, the value inherited from the default server must also be
duplicated. At the end it is safer this way and consistant with the parsing
of the "sni" parameter.

It is harmless so there is no reason to backport this patch.

src/cfgparse-ssl.c
src/check.c
src/server.c

index 0204dca7967fa6feff5c8272485af82683a68bfd..583461d6a2d120d78a84d5dc57b9c90766198635 100644 (file)
@@ -1651,6 +1651,7 @@ static int srv_parse_check_sni(char **args, int *cur_arg, struct proxy *px, stru
                return ERR_ALERT | ERR_FATAL;
        }
 
+       free(newsrv->check.sni);
        newsrv->check.sni = strdup(args[*cur_arg + 1]);
        if (!newsrv->check.sni) {
                memprintf(err, "'%s' : failed to allocate memory", args[*cur_arg]);
index c994108ac499a8c03efe214a85ea83fbeee533fb..186ddb019bc4a3b4abff61d3c118a8d3824ac451 100644 (file)
@@ -1574,6 +1574,7 @@ void free_check(struct check *check)
        }
 
        ha_free(&check->pool_conn_name);
+       ha_free(&check->sni);
        ha_free(&check->alpn_str);
        task_destroy(check->task);
 
index ccaa1665a39bb5ed9ac8edd0eec05fe7d0c826cc..cfdf9cdf2151b2d3163c42f2993729c099dc10a7 100644 (file)
@@ -2900,7 +2900,8 @@ void srv_settings_cpy(struct server *srv, const struct server *src, int srv_tmpl
        srv->agent.addr               = src->agent.addr;
        srv->check.use_ssl            = src->check.use_ssl;
        srv->check.port               = src->check.port;
-       srv->check.sni                = src->check.sni;
+       if (src->check.sni != NULL)
+               srv->check.sni = strdup(src->check.sni);
        if (src->check.alpn_str) {
                srv->check.alpn_str = malloc(src->check.alpn_len);
                if (srv->check.alpn_str) {