diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-11-15 20:32:59 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2023-11-22 09:25:24 +0100 |
commit | ed3d2771278cfa1c355b40c681f5acc8404156c6 (patch) | |
tree | b9dfecbc83d87f1efe716f0f584dce736c297402 /crypto/pkcs7 | |
parent | Fix a possible memory leak in dane_tlsa_add (diff) | |
download | openssl-ed3d2771278cfa1c355b40c681f5acc8404156c6.tar.xz openssl-ed3d2771278cfa1c355b40c681f5acc8404156c6.zip |
Fix a possible memleak in PKCS7_add_attrib_smimecap
When PKCS7_add_signed_attribute fails, the ASN1_STRING
object may be leaked.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22744)
Diffstat (limited to 'crypto/pkcs7')
-rw-r--r-- | crypto/pkcs7/pk7_attr.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c index 68f0a5c290..72690c5e1b 100644 --- a/crypto/pkcs7/pk7_attr.c +++ b/crypto/pkcs7/pk7_attr.c @@ -28,8 +28,12 @@ int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, } seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data, ASN1_ITEM_rptr(X509_ALGORS)); - return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, - V_ASN1_SEQUENCE, seq); + if (!PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, + V_ASN1_SEQUENCE, seq)) { + ASN1_STRING_free(seq); + return 0; + } + return 1; } STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) |