summaryrefslogtreecommitdiffstats
path: root/crypto/property/property_string.c
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-03-14 08:13:12 +0000
committerPauli <pauli@openssl.org>2022-04-01 10:49:19 +1100
commit927d0566ded0dff9d6c5abc8a40bb84068446b76 (patch)
treec6d898a04aaa2062c9a74cb9c89ce25fa9680a41 /crypto/property/property_string.c
parent9c140a33663f319ad4000a6a985c3e14297c7389 (diff)
Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA
This refactors OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA. The assorted objects to be managed by OSSL_LIB_CTX are hardcoded and are initialized eagerly rather than lazily, which avoids the need for locking on access in most cases. Fixes #17116. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17881)
Diffstat (limited to 'crypto/property/property_string.c')
-rw-r--r--crypto/property/property_string.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/crypto/property/property_string.c b/crypto/property/property_string.c
index 9191453d5a..eb48052508 100644
--- a/crypto/property/property_string.c
+++ b/crypto/property/property_string.c
@@ -13,6 +13,7 @@
#include <openssl/lhash.h>
#include "crypto/lhash.h"
#include "property_local.h"
+#include "crypto/context.h"
/*
* Property strings are a consolidation of all strings seen by the property
@@ -72,7 +73,7 @@ static void property_table_free(PROP_TABLE **pt)
}
}
-static void property_string_data_free(void *vpropdata)
+void ossl_property_string_data_free(void *vpropdata)
{
PROPERTY_STRING_DATA *propdata = vpropdata;
@@ -92,7 +93,7 @@ static void property_string_data_free(void *vpropdata)
OPENSSL_free(propdata);
}
-static void *property_string_data_new(OSSL_LIB_CTX *ctx) {
+void *ossl_property_string_data_new(OSSL_LIB_CTX *ctx) {
PROPERTY_STRING_DATA *propdata = OPENSSL_zalloc(sizeof(*propdata));
if (propdata == NULL)
@@ -114,18 +115,12 @@ static void *property_string_data_new(OSSL_LIB_CTX *ctx) {
#endif
|| propdata->prop_names == NULL
|| propdata->prop_values == NULL) {
- property_string_data_free(propdata);
+ ossl_property_string_data_free(propdata);
return NULL;
}
return propdata;
}
-static const OSSL_LIB_CTX_METHOD property_string_data_method = {
- OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY,
- property_string_data_new,
- property_string_data_free,
-};
-
static PROPERTY_STRING *new_property_string(const char *s,
OSSL_PROPERTY_IDX *pidx)
{
@@ -151,8 +146,7 @@ static OSSL_PROPERTY_IDX ossl_property_string(OSSL_LIB_CTX *ctx, int name,
PROP_TABLE *t;
OSSL_PROPERTY_IDX *pidx;
PROPERTY_STRING_DATA *propdata
- = ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_PROPERTY_STRING_INDEX,
- &property_string_data_method);
+ = ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_PROPERTY_STRING_INDEX);
if (propdata == NULL)
return 0;
@@ -224,8 +218,7 @@ static const char *ossl_property_str(int name, OSSL_LIB_CTX *ctx,
{
const char *r;
PROPERTY_STRING_DATA *propdata
- = ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_PROPERTY_STRING_INDEX,
- &property_string_data_method);
+ = ossl_lib_ctx_get_data(ctx, OSSL_LIB_CTX_PROPERTY_STRING_INDEX);
if (propdata == NULL)
return NULL;