summaryrefslogtreecommitdiffstats
path: root/crypto/context.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-08-14 15:00:35 +0100
committerMatt Caswell <matt@openssl.org>2019-08-29 10:50:47 +0100
commit505f46602043c7c28884e4c13f3cfa9419ae2f15 (patch)
tree0c58220dd5f6b3f5d29e0a832b20dfa4a0e5872a /crypto/context.c
parent770de3462c0d655a6543a6c1a2c0bda7b57178f9 (diff)
Make sure we pre-initialise properties
Simplify the initialisation of the core by pre-initialising properties. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9590)
Diffstat (limited to 'crypto/context.c')
-rw-r--r--crypto/context.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/context.c b/crypto/context.c
index ad4e997a7c..a2e19bac54 100644
--- a/crypto/context.c
+++ b/crypto/context.c
@@ -9,6 +9,7 @@
#include "internal/cryptlib_int.h"
#include "internal/thread_once.h"
+#include "internal/property.h"
struct openssl_ctx_onfree_list_st {
openssl_ctx_onfree_fn *fn;
@@ -47,6 +48,7 @@ static OPENSSL_CTX *default_context = NULL;
static int context_init(OPENSSL_CTX *ctx)
{
size_t i;
+ int exdata_done = 0;
ctx->lock = CRYPTO_THREAD_lock_new();
if (ctx->lock == NULL)
@@ -63,8 +65,10 @@ static int context_init(OPENSSL_CTX *ctx)
goto err;
}
+ /* OPENSSL_CTX is built on top of ex_data so we initialise that directly */
if (!do_ex_data_init(ctx))
goto err;
+ exdata_done = 1;
if (!crypto_new_ex_data_ex(ctx, CRYPTO_EX_INDEX_OPENSSL_CTX, NULL,
&ctx->data)) {
@@ -72,8 +76,14 @@ static int context_init(OPENSSL_CTX *ctx)
goto err;
}
+ /* Everything depends on properties, so we also pre-initialise that */
+ if (!ossl_property_parse_init(ctx))
+ goto err;
+
return 1;
err:
+ if (exdata_done)
+ crypto_cleanup_all_ex_data_int(ctx);
CRYPTO_THREAD_lock_free(ctx->oncelock);
CRYPTO_THREAD_lock_free(ctx->lock);
ctx->lock = NULL;