summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-06-07 18:49:29 +0200
committerTomas Mraz <tomas@openssl.org>2022-06-10 14:08:59 +0200
commite10ebdd81e6f5b6eb00fb25476bbd8cc19c9c83c (patch)
tree46abff3df093bbc071b54399915723ab1ade3fc9 /crypto/evp
parent0faf842e5e3406356deffa9a2d40716852bce8bb (diff)
Check return of BIO_new() and always free pkey from evp_pkey_copy_downgraded()
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18494) (cherry picked from commit d8732803c493cba7a863c5c16da62ee9d611c5ca)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/p_lib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index ed228a1bd4..db1822f0d1 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -1123,8 +1123,11 @@ static int print_set_indent(BIO **out, int *pop_f_prefix, long *saved_indent,
*saved_indent = (i < 0 ? 0 : i);
if (BIO_set_indent(*out, indent) <= 0) {
- if ((*out = BIO_push(BIO_new(BIO_f_prefix()), *out)) == NULL)
+ BIO *prefbio = BIO_new(BIO_f_prefix());
+
+ if (prefbio == NULL)
return 0;
+ *out = BIO_push(prefbio, *out);
*pop_f_prefix = 1;
}
if (BIO_set_indent(*out, indent) <= 0) {
@@ -2090,7 +2093,7 @@ void *evp_pkey_get_legacy(EVP_PKEY *pk)
return ret;
if (!evp_pkey_copy_downgraded(&tmp_copy, pk))
- return NULL;
+ goto err;
if (!CRYPTO_THREAD_write_lock(pk->lock))
goto err;