]> 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:26:10 +0000 (12:26 +0200)
commitfab9111520f17be27dead558fb0230c1653f7610
treee29a653d217c35a1e5d0e019fdb510606bec2bb1
parent658e53b4efa1ca55e9ea2ad8f03971fcc85aad17
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)

(cherry picked from commit 82a13a1f5053462f826bfb90061f0f77e3cc98a5)
crypto/pkcs7/pk7_doit.c