Allocates and initializes pubkey in X509_PUBKEY_dup()

Fixes #14617

Signed-off-by: Sahana Prasad <sahana@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14642)
This commit is contained in:
Sahana Prasad 2021-03-22 11:04:45 +01:00 committed by Pauli
parent a638fb9413
commit f0800c7c22

View File

@ -209,7 +209,8 @@ X509_PUBKEY *X509_PUBKEY_dup(const X509_PUBKEY *a)
{
X509_PUBKEY *pubkey = NULL;
if (!x509_pubkey_ex_new(NULL, ASN1_ITEM_rptr(X509_PUBKEY_INTERNAL))
if (!x509_pubkey_ex_new((ASN1_VALUE **)&pubkey,
ASN1_ITEM_rptr(X509_PUBKEY_INTERNAL))
|| !x509_pubkey_set0_libctx(pubkey, a->libctx, a->propq)
|| (pubkey->algor = X509_ALGOR_dup(a->algor)) == NULL
|| (pubkey->public_key = ASN1_BIT_STRING_new()) == NULL