do_ext_i2d(): avoid leaks and add some missing error checking
authortb <tb@openbsd.org>
Tue, 18 Jun 2024 05:32:38 +0000 (05:32 +0000)
committertb <tb@openbsd.org>
Tue, 18 Jun 2024 05:32:38 +0000 (05:32 +0000)
commit196aed94a987cc81fa0715235a1fe9021ef352dc
tree47d830ceb6f1e4d45b82d40d6c2d4485e44be931
parent79df864cec459300aa382c4f7d4634f08ef2b400
do_ext_i2d(): avoid leaks and add some missing error checking

If ASN1_OCTET_STRING_new() failed, ext_der would be leaked, fix this.
If i2d(foo, NULL) succeeded, the same is not guaranteed for the second
with appropriately sized buffer since i2d() may make further allocations
internally. So use the proper error check. Also transfer the ownership of
ext_der to the octet string to avoid a now possible double free.

ok jsing
lib/libcrypto/x509/x509_conf.c