Skip to content

Commit f8b7299

Browse files
committed
BUG/MINOR: server: Duplicate healthcheck's sni inherited from default server
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.
1 parent f7a04b4 commit f8b7299

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/cfgparse-ssl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,7 @@ static int srv_parse_check_sni(char **args, int *cur_arg, struct proxy *px, stru
16511651
return ERR_ALERT | ERR_FATAL;
16521652
}
16531653

1654+
free(newsrv->check.sni);
16541655
newsrv->check.sni = strdup(args[*cur_arg + 1]);
16551656
if (!newsrv->check.sni) {
16561657
memprintf(err, "'%s' : failed to allocate memory", args[*cur_arg]);

src/check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ void free_check(struct check *check)
15741574
}
15751575

15761576
ha_free(&check->pool_conn_name);
1577+
ha_free(&check->sni);
15771578
ha_free(&check->alpn_str);
15781579
task_destroy(check->task);
15791580

src/server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2900,7 +2900,8 @@ void srv_settings_cpy(struct server *srv, const struct server *src, int srv_tmpl
29002900
srv->agent.addr = src->agent.addr;
29012901
srv->check.use_ssl = src->check.use_ssl;
29022902
srv->check.port = src->check.port;
2903-
srv->check.sni = src->check.sni;
2903+
if (src->check.sni != NULL)
2904+
srv->check.sni = strdup(src->check.sni);
29042905
if (src->check.alpn_str) {
29052906
srv->check.alpn_str = malloc(src->check.alpn_len);
29062907
if (srv->check.alpn_str) {

0 commit comments

Comments
 (0)