In {RSA,DSA,DH}_new_method(x) need to increase the reference
authorDr. Stephen Henson <steve@openssl.org>
Sat, 23 Jun 2001 23:07:34 +0000 (23:07 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sat, 23 Jun 2001 23:07:34 +0000 (23:07 +0000)
count of the ENGINE is x is not NULL since it will be freed
in {RSA,DSA,DH}_free().

crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c
crypto/rsa/rsa_lib.c

index b3c609e8be08127014384e323b3b41438047556a..2d778ef300cfe989fa24de870310230ba27f70e5 100644 (file)
@@ -142,16 +142,21 @@ DH *DH_new_method(ENGINE *engine)
                DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
-       if(engine)
-               ret->engine = engine;
+
+       if (engine)
+               {
+               if(ENGINE_init(engine))
+                       ret->engine = engine;
+               else 
+                       ret->engine = NULL;
+               }
        else
+               ret->engine=ENGINE_get_default_DH();
+       if(ret->engine == NULL)
                {
-               if((ret->engine=ENGINE_get_default_DH()) == NULL)
-                       {
-                       DHerr(DH_F_DH_NEW,ERR_LIB_ENGINE);
-                       OPENSSL_free(ret);
-                       return NULL;
-                       }
+               DHerr(DH_F_DH_NEW,ERR_LIB_ENGINE);
+               OPENSSL_free(ret);
+               return NULL;
                }
        meth = ENGINE_get_DH(ret->engine);
        ret->pad=0;
index 1b33705f46357721761b431b1a59d55f215c0f9b..48b228f3a129f3f392d88b1208405111538a8ac5 100644 (file)
@@ -146,17 +146,24 @@ DSA *DSA_new_method(ENGINE *engine)
                DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
-       if(engine)
-               ret->engine = engine;
+
+       if (engine)
+               {
+               if(ENGINE_init(engine))
+                       ret->engine = engine;
+               else 
+                       ret->engine = NULL;
+               }
        else
+               ret->engine=ENGINE_get_default_DSA();
+
+       if(ret->engine == NULL)
                {
-               if((ret->engine=ENGINE_get_default_DSA()) == NULL)
-                       {
-                       DSAerr(DSA_F_DSA_NEW,ERR_LIB_ENGINE);
-                       OPENSSL_free(ret);
-                       return NULL;
-                       }
+               DSAerr(DSA_F_DSA_NEW,ERR_LIB_ENGINE);
+               OPENSSL_free(ret);
+               return NULL;
                }
+
        meth = ENGINE_get_DSA(ret->engine);
        ret->pad=0;
        ret->version=0;
index 3a4760c8d4e31ae4a54d441e8f246d3552184ba2..315671a60e501fc6a001501c847ce45707d7d907 100644 (file)
@@ -162,17 +162,23 @@ RSA *RSA_new_method(ENGINE *engine)
                return(NULL);
                }
 
-       if (engine == NULL)
+       if (engine)
                {
-               if((ret->engine=ENGINE_get_default_RSA()) == NULL)
-                       {
-                       RSAerr(RSA_F_RSA_NEW_METHOD,ERR_LIB_ENGINE);
-                       OPENSSL_free(ret);
-                       return NULL;
-                       }
+               if(ENGINE_init(engine))
+                       ret->engine = engine;
+               else 
+                       ret->engine = NULL;
                }
        else
-               ret->engine=engine;
+               ret->engine=ENGINE_get_default_RSA();
+
+       if(ret->engine == NULL)
+               {
+               RSAerr(RSA_F_RSA_NEW_METHOD,ERR_LIB_ENGINE);
+               OPENSSL_free(ret);
+               return NULL;
+               }
+
        meth = ENGINE_get_RSA(ret->engine);
 
        ret->pad=0;