]> git.ipfire.org Git - thirdparty/openssl.git/commit
Fix possible double-free in pkcs7 add_attribute function
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Tue, 14 Nov 2023 01:55:36 +0000 (02:55 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 8 Jul 2024 10:25:45 +0000 (12:25 +0200)
commit82a13a1f5053462f826bfb90061f0f77e3cc98a5
tree14daa8e8b6ca16ddbcda9cb9cffa02cc5006b22b
parent29696af689df734cae05181d85ee04470c3839d3
Fix possible double-free in pkcs7 add_attribute function

The problem is the ownership of the input parameter value
is transfered to the X509_ATTRIBUTE object attr, as soon
as X509_ATTRIBUTE_create succeeds, but when an error happens
after that point there is no way to get the ownership back
to the caller, which is necessary to fullfill the API contract.

Fixed that by moving the call to X509_ATTRIBUTE_create to the
end of the function, and make sure that no errors are possible
after that point.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22721)
crypto/pkcs7/pk7_doit.c