From: Olivier Houchard Date: Wed, 25 Nov 2026 16:47:42 +0000 (+0100) Subject: BUG/MEDIUM: ssl/cli: restore the store conf on "add ssl crt-list" error X-Git-Tag: v3.5-dev14~17 X-Git-Url: https://git.kaiwu.me/http/ngx_http_ssi_module.html?a=commitdiff_plain;h=29225103f;p=haproxy.git BUG/MEDIUM: ssl/cli: restore the store conf on "add ssl crt-list" error In cli_parse_add_crtlist(), a store without any instance adopts the ckch_conf parsed from the line, but if the line is rejected afterwards, the error path frees the content of that conf, and the store keeps pointers to freed strings. They are then printed by "show ssl cert" and freed again by "del ssl cert". It can be triggered by adding a certificate created with "new ssl cert" to a crt-list which is a directory, using crt-store keywords such as "key" or "issuer". Let's save the previous conf of the store and restore it on error, so that a rejected line doesn't change the store. This was introduced by commit 1bc6e990f ("MEDIUM: ssl/cli: handle crt-store keywords in crt-list over the CLI") in 3.0-dev12, so this should be backported to 3.0. --- diff --git a/src/ssl_crtlist.c b/src/ssl_crtlist.c index 494b5ea23..a3fb79618 100644 --- a/src/ssl_crtlist.c +++ b/src/ssl_crtlist.c @@ -1343,6 +1343,8 @@ static int cli_parse_add_crtlist(char **args, char *payload, struct appctx *appc struct crtlist *crtlist; struct crtlist_entry *entry = NULL; struct ckch_conf cc = {}; + struct ckch_conf old_cc = {}; + int adopted = 0; char *end; if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) @@ -1422,7 +1424,9 @@ static int cli_parse_add_crtlist(char **args, char *payload, struct appctx *appc */ if (LIST_ISEMPTY(&store->ckch_inst)) { + old_cc = store->conf; store->conf = cc; + adopted = 1; /* fresh new, run more init (for example init ocsp-update tasks) */ cfgerr |= ckch_store_load_files(&cc, store, 1, "CLI", 1, &err); if (cfgerr & ERR_FATAL) @@ -1460,6 +1464,9 @@ static int cli_parse_add_crtlist(char **args, char *payload, struct appctx *appc return 0; error: + /* the store must not keep the conf freed below */ + if (adopted) + store->conf = old_cc; ckch_conf_clean(&cc); crtlist_entry_free(entry); HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);