aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2001-09-05 19:00:33 +0000
committerGeoff Thorpe <geoff@openssl.org>2001-09-05 19:00:33 +0000
commit1a7691c0594a46015f8695a623c9f8934ab641e2 (patch)
tree1f50425bd22e7acf889de909c5b78c282ffd829a
parentf524ddbe049e260763d410cd41fc66bdaf4b01e5 (diff)
downloadopenssl-1a7691c0594a46015f8695a623c9f8934ab641e2.tar.gz
This adds "destroy" handlers to the existing ENGINEs that load their own
error strings - the destroy handler functions unload the error strings so any pending error state referring to them will not attempt to reference them after the ENGINE has been destroyed.
-rw-r--r--crypto/engine/hw_atalla.c21
-rw-r--r--crypto/engine/hw_cswift.c18
-rw-r--r--crypto/engine/hw_ncipher.c22
-rw-r--r--crypto/engine/hw_nuron.c20
-rw-r--r--crypto/engine/hw_ubsec.c22
5 files changed, 97 insertions, 6 deletions
diff --git a/crypto/engine/hw_atalla.c b/crypto/engine/hw_atalla.c
index 5716c2f0b9..88719beb79 100644
--- a/crypto/engine/hw_atalla.c
+++ b/crypto/engine/hw_atalla.c
@@ -71,6 +71,7 @@
#include "vendor_defns/atalla.h"
#endif
+static int atalla_destroy(ENGINE *e);
static int atalla_init(ENGINE *e);
static int atalla_finish(ENGINE *e);
static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
@@ -215,9 +216,18 @@ static void atalla_load_error_strings(void)
ERR_load_strings(atalla_err_lib,atalla_str_functs);
}
}
+static void atalla_unload_error_strings(void)
+ {
+ if (atalla_err_lib >= 0)
+ {
+ ERR_unload_strings(atalla_err_lib,atalla_str_functs);
+ atalla_err_lib = -1;
+ }
+ }
#else
#define ATALLAerr(f,r) /* NOP */
static void atalla_load_error_strings(void) { } /* NOP */
+static void atalla_unload_error_strings(void) { } /* NOP */
#endif
/* Constants used when creating the ENGINE */
@@ -249,6 +259,7 @@ static int bind_helper(ENGINE *e)
!ENGINE_set_DH(e, &atalla_dh) ||
#endif
!ENGINE_set_BN_mod_exp(e, atalla_mod_exp) ||
+ !ENGINE_set_destroy_function(e, atalla_destroy) ||
!ENGINE_set_init_function(e, atalla_init) ||
!ENGINE_set_finish_function(e, atalla_finish) ||
!ENGINE_set_ctrl_function(e, atalla_ctrl) ||
@@ -333,6 +344,16 @@ static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
+/* Destructor (complements the "ENGINE_atalla()" constructor) */
+static int atalla_destroy(ENGINE *e)
+ {
+ /* Unload the atalla error strings so any error state including our
+ * functs or reasons won't lead to a segfault (they simply get displayed
+ * without corresponding string data because none will be found). */
+ atalla_unload_error_strings();
+ return 1;
+ }
+
/* (de)initialisation functions. */
static int atalla_init(ENGINE *e)
{
diff --git a/crypto/engine/hw_cswift.c b/crypto/engine/hw_cswift.c
index 4eab0fb769..e7d5bdcd49 100644
--- a/crypto/engine/hw_cswift.c
+++ b/crypto/engine/hw_cswift.c
@@ -83,6 +83,7 @@
#include "vendor_defns/cswift.h"
#endif
+static int cswift_destroy(ENGINE *e);
static int cswift_init(ENGINE *e);
static int cswift_finish(ENGINE *e);
static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
@@ -236,9 +237,18 @@ static void cswift_load_error_strings(void)
ERR_load_strings(cswift_err_lib, cswift_str_functs);
}
}
+static void cswift_unload_error_strings(void)
+ {
+ if(cswift_err_lib >= 0)
+ {
+ ERR_unload_strings(cswift_err_lib, cswift_str_functs);
+ cswift_err_lib = -1;
+ }
+ }
#else
#define CSWIFTerr(f,r) /* NOP */
static void cswift_load_error_strings(void) { } /* NOP */
+static void cswift_unload_error_strings(void) { } /* NOP */
#endif
/* Constants used when creating the ENGINE */
@@ -268,6 +278,7 @@ static int bind_helper(ENGINE *e)
#endif
!ENGINE_set_BN_mod_exp(e, &cswift_mod_exp) ||
!ENGINE_set_BN_mod_exp_crt(e, &cswift_mod_exp_crt) ||
+ !ENGINE_set_destroy_function(e, cswift_destroy) ||
!ENGINE_set_init_function(e, cswift_init) ||
!ENGINE_set_finish_function(e, cswift_finish) ||
!ENGINE_set_ctrl_function(e, cswift_ctrl) ||
@@ -361,6 +372,13 @@ static void release_context(SW_CONTEXT_HANDLE hac)
p_CSwift_ReleaseAccContext(hac);
}
+/* Destructor (complements the "ENGINE_cswift()" constructor) */
+static int cswift_destroy(ENGINE *e)
+ {
+ cswift_unload_error_strings();
+ return 1;
+ }
+
/* (de)initialisation functions. */
static int cswift_init(ENGINE *e)
{
diff --git a/crypto/engine/hw_ncipher.c b/crypto/engine/hw_ncipher.c
index 03990c558c..db55b1a350 100644
--- a/crypto/engine/hw_ncipher.c
+++ b/crypto/engine/hw_ncipher.c
@@ -83,6 +83,7 @@
#include "vendor_defns/hwcryptohook.h"
#endif
+static int hwcrhk_destroy(ENGINE *e);
static int hwcrhk_init(ENGINE *e);
static int hwcrhk_finish(ENGINE *e);
static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
@@ -281,9 +282,18 @@ static void hwcrhk_load_error_strings(void)
ERR_load_strings(hwcrhk_err_lib, hwcrhk_str_functs);
}
}
+static void hwcrhk_unload_error_strings(void)
+ {
+ if(hwcrhk_err_lib >= 0)
+ {
+ ERR_unload_strings(hwcrhk_err_lib, hwcrhk_str_functs);
+ hwcrhk_err_lib = -1;
+ }
+ }
#else
-#define HWCRHKerr(f,r) /* NOP */
-static void hwcrhk_load_error_strings(void) { } /* NOP */
+#define HWCRHKerr(f,r) /* NOP */
+static void hwcrhk_load_error_strings(void) { } /* NOP */
+static void hwcrhk_unload_error_strings(void) { } /* NOP */
#endif
/* Constants used when creating the ENGINE */
@@ -408,6 +418,7 @@ static int bind_helper(ENGINE *e)
#endif
!ENGINE_set_RAND(e, &hwcrhk_rand) ||
!ENGINE_set_BN_mod_exp(e, hwcrhk_mod_exp) ||
+ !ENGINE_set_destroy_function(e, hwcrhk_destroy) ||
!ENGINE_set_init_function(e, hwcrhk_init) ||
!ENGINE_set_finish_function(e, hwcrhk_finish) ||
!ENGINE_set_ctrl_function(e, hwcrhk_ctrl) ||
@@ -530,6 +541,13 @@ static void release_context(HWCryptoHook_ContextHandle hac)
p_hwcrhk_Finish(hac);
}
+/* Destructor (complements the "ENGINE_ncipher()" constructor) */
+static int hwcrhk_destroy(ENGINE *e)
+ {
+ hwcrhk_unload_error_strings();
+ return 1;
+ }
+
/* (de)initialisation functions. */
static int hwcrhk_init(ENGINE *e)
{
diff --git a/crypto/engine/hw_nuron.c b/crypto/engine/hw_nuron.c
index 1a8570c47e..5ca10be771 100644
--- a/crypto/engine/hw_nuron.c
+++ b/crypto/engine/hw_nuron.c
@@ -125,9 +125,18 @@ static void nuron_load_error_strings(void)
ERR_load_strings(nuron_err_lib, nuron_str_functs);
}
}
+static void nuron_unload_error_strings(void)
+ {
+ if(nuron_err_lib >= 0)
+ {
+ ERR_unload_strings(nuron_err_lib, nuron_str_functs);
+ nuron_err_lib = -1;
+ }
+ }
#else
-#define NURONerr(f,r) /* NOP */
-static void nuron_load_error_strings(void) { } /* NOP */
+#define NURONerr(f,r) /* NOP */
+static void nuron_load_error_strings(void) { } /* NOP */
+static void nuron_unload_error_strings(void) { } /* NOP */
#endif
typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
@@ -135,6 +144,12 @@ static tfnModExp *pfnModExp = NULL;
static DSO *pvDSOHandle = NULL;
+static int nuron_destroy(ENGINE *e)
+ {
+ nuron_unload_error_strings();
+ return 1;
+ }
+
static int nuron_init(ENGINE *e)
{
if(pvDSOHandle != NULL)
@@ -356,6 +371,7 @@ static int bind_helper(ENGINE *e)
!ENGINE_set_DH(e, &nuron_dh) ||
#endif
!ENGINE_set_BN_mod_exp(e, nuron_mod_exp) ||
+ !ENGINE_set_destroy_function(e, nuron_destroy) ||
!ENGINE_set_init_function(e, nuron_init) ||
!ENGINE_set_finish_function(e, nuron_finish) ||
!ENGINE_set_ctrl_function(e, nuron_ctrl) ||
diff --git a/crypto/engine/hw_ubsec.c b/crypto/engine/hw_ubsec.c
index f2d5a34a78..c8a6acd7e6 100644
--- a/crypto/engine/hw_ubsec.c
+++ b/crypto/engine/hw_ubsec.c
@@ -73,6 +73,7 @@
#include "vendor_defns/hw_ubsec.h"
#endif
+static int ubsec_destroy(ENGINE *e);
static int ubsec_init(ENGINE *e);
static int ubsec_finish(ENGINE *e);
static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
@@ -230,9 +231,18 @@ static void ubsec_load_error_strings(void)
ERR_load_strings(ubsec_err_lib, ubsec_str_functs);
}
}
+static void ubsec_unload_error_strings(void)
+ {
+ if(ubsec_err_lib >= 0)
+ {
+ ERR_unload_strings(ubsec_err_lib, ubsec_str_functs);
+ ubsec_err_lib = -1;
+ }
+ }
#else
-#define UBSECerr(f,r) /* NOP */
-static void ubsec_load_error_strings(void) { } /* NOP */
+#define UBSECerr(f,r) /* NOP */
+static void ubsec_load_error_strings(void) { } /* NOP */
+static void ubsec_unload_error_strings(void) { } /* NOP */
#endif
/* Constants used when creating the ENGINE */
@@ -264,6 +274,7 @@ static int bind_helper(ENGINE *e)
#endif
!ENGINE_set_BN_mod_exp(e, ubsec_mod_exp) ||
!ENGINE_set_BN_mod_exp_crt(e, ubsec_mod_exp_crt) ||
+ !ENGINE_set_destroy_function(e, ubsec_destroy) ||
!ENGINE_set_init_function(e, ubsec_init) ||
!ENGINE_set_finish_function(e, ubsec_finish) ||
!ENGINE_set_ctrl_function(e, ubsec_ctrl) ||
@@ -370,6 +381,13 @@ static const char *UBSEC_F10 = "dsa_verify_ioctl";
static const char *UBSEC_F11 = "math_accelerate_ioctl";
static const char *UBSEC_F12 = "rng_ioctl";
+/* Destructor (complements the "ENGINE_ubsec()" constructor) */
+static int ubsec_destroy(ENGINE *e)
+ {
+ ubsec_unload_error_strings();
+ return 1;
+ }
+
/* (de)initialisation functions. */
static int ubsec_init(ENGINE *e)
{