[openssl] openssl-3.0 update

Dr. Paul Dale pauli at openssl.org
Fri Jan 7 10:09:08 UTC 2022


The branch openssl-3.0 has been updated
       via  e33f05660447c69e89f2e9f5d3140a56322411d5 (commit)
      from  277a8334cd4a213619fe92107dd393eab6d8a801 (commit)


- Log -----------------------------------------------------------------
commit e33f05660447c69e89f2e9f5d3140a56322411d5
Author: Peiwei Hu <jlu.hpw at foxmail.com>
Date:   Thu Jan 6 09:47:05 2022 +0800

    providers/implementations/keymgmt/rsa_kmgmt.c: refactor gen_init
    
    There is risk to pass the gctx with NULL value to rsa_gen_set_params
    which dereference gctx directly.
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/17429)
    
    (cherry picked from commit 22778abad905536fa6c93cdc6fffc8c736dfee79)

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

Summary of changes:
 providers/implementations/keymgmt/rsa_kmgmt.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/providers/implementations/keymgmt/rsa_kmgmt.c b/providers/implementations/keymgmt/rsa_kmgmt.c
index b1c3011f14..29e5d10813 100644
--- a/providers/implementations/keymgmt/rsa_kmgmt.c
+++ b/providers/implementations/keymgmt/rsa_kmgmt.c
@@ -454,19 +454,24 @@ static void *gen_init(void *provctx, int selection, int rsa_type,
         gctx->libctx = libctx;
         if ((gctx->pub_exp = BN_new()) == NULL
             || !BN_set_word(gctx->pub_exp, RSA_F4)) {
-            BN_free(gctx->pub_exp);
-            OPENSSL_free(gctx);
-            return NULL;
+            goto err;
         }
         gctx->nbits = 2048;
         gctx->primes = RSA_DEFAULT_PRIME_NUM;
         gctx->rsa_type = rsa_type;
+    } else {
+        goto err;
     }
-    if (!rsa_gen_set_params(gctx, params)) {
-        OPENSSL_free(gctx);
-        return NULL;
-    }
+
+    if (!rsa_gen_set_params(gctx, params))
+        goto err;
     return gctx;
+
+err:
+    if (gctx != NULL)
+        BN_free(gctx->pub_exp);
+    OPENSSL_free(gctx);
+    return NULL;
 }
 
 static void *rsa_gen_init(void *provctx, int selection,


More information about the openssl-commits mailing list