Fix leaks in copy_issuer()
authortb <tb@openbsd.org>
Wed, 30 Aug 2023 00:49:32 +0000 (00:49 +0000)
committertb <tb@openbsd.org>
Wed, 30 Aug 2023 00:49:32 +0000 (00:49 +0000)
commitc44a41966433acebbe0435c2cf9b75865bafb487
tree969987a456c51ba6f07c920363b2c11756a99941
parenta077d710c2f5440af9dfa06e50044422447386f8
Fix leaks in copy_issuer()

The stack of subject alternative names from the issuer is parsed using
X509V3_EXT_d2i(), so it must be freed with sk_GENERAL_NAME_pop_free().
It's not worth doing complicated ownership handling when the individual
alternative names can be copied with GENERAL_NAME_dup().

Previously, ialt and its remaining members would be leaked when the call
to sk_GENERAL_NAME_push() failed halfway through.

This is only reachable via the issuer:copy x509v3.cnf(5) directive.

ok jsing
lib/libcrypto/x509/x509_alt.c