]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: ssl/ckch: free the new instance when ckch_inst_rebuild() fails
authorChris Staite <christopher.staite@menlosecurity.com>
Mon, 2 Nov 2026 10:00:56 +0000 (10:00 +0000)
committerWilliam Lallemand <wlallemand@irq6.net>
Tue, 3 Nov 2026 16:27:44 +0000 (17:27 +0100)
commita4f92a7433f8fa6aa7b4b63d924f534720e17ba0
treebfbfd1c8b992a72567221235f07668a8af6cc6b5
parent234a834317c51bbdcb5712596a570db36f4f2cb2
BUG/MINOR: ssl/ckch: free the new instance when ckch_inst_rebuild() fails

ckch_inst_rebuild() creates the new ckch_inst of a "commit ssl cert" with
its sni_ctx and SSL_CTX, then prepares the SSL_CTX of the server or of
the bind line. When this preparation fails it returns an error to
ckch_store_rebuild_instances() which only returns -1, so the new instance,
which is not linked anywhere yet, is leaked with its SSL_CTXs, and with
everything they reference (the certificate, the chain, the key, the CA
file links).

The impact is a memory leak for each failed commit, which requires an
admin to commit a certificate that doesn't fit its bind or server lines.

Free the instance with ckch_inst_free() and reset the pointer on these
two error paths. The instance is not in any tree nor list at this point,
which ckch_inst_free() handles. The first error path, after
ckch_inst_new_load_store() or ckch_inst_new_load_srv_store(), is already
fine since these functions never leave an instance behind on failure.

This should be backported to all stable branches, the function exists
since 2.5.
src/ssl_ckch.c