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.
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))
*/
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)
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);