]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Check return of BIO_new() and always free pkey from evp_pkey_copy_downgraded()
authorTomas Mraz <tomas@openssl.org>
Tue, 7 Jun 2022 16:49:29 +0000 (18:49 +0200)
committerTomas Mraz <tomas@openssl.org>
Fri, 10 Jun 2022 12:06:57 +0000 (14:06 +0200)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18494)

crypto/evp/p_lib.c

index ed228a1bd43650c6b5ed03b683405d9d2f9ddae3..db1822f0d1bce3a922c6045093efaeae61906b5b 100644 (file)
@@ -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;