]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: acme: fix multiple resource leaks in acme_x509_req()
authorDavid Carlier <devnexen@gmail.com>
Fri, 20 Mar 2026 16:39:28 +0000 (16:39 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 23 Mar 2026 09:44:42 +0000 (10:44 +0100)
commit8e469ebf2ebef565d3fcaa0d6ad9ac5998734e24
tree232c4ec448f05e0a4b21783678b9bfdb4b15c693
parentff7b06badb4d39cf7f8f054e26c2f31154e5850d
BUG/MEDIUM: acme: fix multiple resource leaks in acme_x509_req()

Several resources were leaked on both success and error paths:

- X509_NAME *nm was never freed. X509_REQ_set_subject_name() makes
  an internal copy, so nm must be freed separately by the caller.
- str_san allocated via my_strndup() was never freed on either path.
- On error paths after allocation, x (X509_REQ) and exts
  (STACK_OF(X509_EXTENSION)) were also leaked.

Fix this by adding proper cleanup of all allocated resources in both
the success and error paths. Also move sk_X509_EXTENSION_pop_free()
after X509_REQ_sign() so it is not skipped when sign fails, and
initialize nm to NULL to make early error paths safe.

Must be backported as far as 3.2.
src/acme.c