[openssl] OpenSSL_1_1_1-stable update

tomas at openssl.org tomas at openssl.org
Fri Jul 23 07:06:53 UTC 2021


The branch OpenSSL_1_1_1-stable has been updated
       via  ba4c89a9700ff07cecde90248707056292bf36d1 (commit)
      from  d9d838ddc0ed083fb4c26dd067e71aad7c65ad16 (commit)


- Log -----------------------------------------------------------------
commit ba4c89a9700ff07cecde90248707056292bf36d1
Author: Tomas Mraz <tomas at openssl.org>
Date:   Wed Jul 21 18:45:01 2021 +0200

    DSA/RSA_print(): Fix potential memory leak
    
    Fixes #10777
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/16130)
    
    (cherry picked from commit 40184c96103a388209939c1c19920971c05bb78c)

-----------------------------------------------------------------------

Summary of changes:
 crypto/dsa/dsa_prn.c | 12 ++++++++----
 crypto/rsa/rsa_prn.c |  6 ++++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/crypto/dsa/dsa_prn.c b/crypto/dsa/dsa_prn.c
index a4a1fd5650..6bc336c50e 100644
--- a/crypto/dsa/dsa_prn.c
+++ b/crypto/dsa/dsa_prn.c
@@ -49,9 +49,11 @@ int DSA_print(BIO *bp, const DSA *x, int off)
     EVP_PKEY *pk;
     int ret;
     pk = EVP_PKEY_new();
-    if (pk == NULL || !EVP_PKEY_set1_DSA(pk, (DSA *)x))
+    if (pk == NULL)
         return 0;
-    ret = EVP_PKEY_print_private(bp, pk, off, NULL);
+    ret = EVP_PKEY_set1_DSA(pk, (DSA *)x);
+    if (ret)
+        ret = EVP_PKEY_print_private(bp, pk, off, NULL);
     EVP_PKEY_free(pk);
     return ret;
 }
@@ -61,9 +63,11 @@ int DSAparams_print(BIO *bp, const DSA *x)
     EVP_PKEY *pk;
     int ret;
     pk = EVP_PKEY_new();
-    if (pk == NULL || !EVP_PKEY_set1_DSA(pk, (DSA *)x))
+    if (pk == NULL)
         return 0;
-    ret = EVP_PKEY_print_params(bp, pk, 4, NULL);
+    ret = EVP_PKEY_set1_DSA(pk, (DSA *)x);
+    if (ret)
+        ret = EVP_PKEY_print_params(bp, pk, 4, NULL);
     EVP_PKEY_free(pk);
     return ret;
 }
diff --git a/crypto/rsa/rsa_prn.c b/crypto/rsa/rsa_prn.c
index b5f4bce2a3..0d97e57eb1 100644
--- a/crypto/rsa/rsa_prn.c
+++ b/crypto/rsa/rsa_prn.c
@@ -34,9 +34,11 @@ int RSA_print(BIO *bp, const RSA *x, int off)
     EVP_PKEY *pk;
     int ret;
     pk = EVP_PKEY_new();
-    if (pk == NULL || !EVP_PKEY_set1_RSA(pk, (RSA *)x))
+    if (pk == NULL)
         return 0;
-    ret = EVP_PKEY_print_private(bp, pk, off, NULL);
+    ret = EVP_PKEY_set1_RSA(pk, (RSA *)x);
+    if (ret)
+        ret = EVP_PKEY_print_private(bp, pk, off, NULL);
     EVP_PKEY_free(pk);
     return ret;
 }


More information about the openssl-commits mailing list