summaryrefslogtreecommitdiffstats
path: root/crypto/property
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/property')
-rw-r--r--crypto/property/defn_cache.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/crypto/property/defn_cache.c b/crypto/property/defn_cache.c
index b3aefe8f8e..13b2d60770 100644
--- a/crypto/property/defn_cache.c
+++ b/crypto/property/defn_cache.c
@@ -13,6 +13,7 @@
#include <openssl/lhash.h>
#include "internal/propertyerr.h"
#include "internal/property.h"
+#include "internal/core.h"
#include "property_local.h"
/*
@@ -74,11 +75,12 @@ OSSL_PROPERTY_LIST *ossl_prop_defn_get(OSSL_LIB_CTX *ctx, const char *prop)
property_defns = ossl_lib_ctx_get_data(ctx,
OSSL_LIB_CTX_PROPERTY_DEFN_INDEX,
&property_defns_method);
- if (property_defns == NULL)
+ if (property_defns == NULL || !ossl_lib_ctx_read_lock(ctx))
return NULL;
elem.prop = prop;
r = lh_PROPERTY_DEFN_ELEM_retrieve(property_defns, &elem);
+ ossl_lib_ctx_unlock(ctx);
return r != NULL ? r->defn : NULL;
}
@@ -88,6 +90,7 @@ int ossl_prop_defn_set(OSSL_LIB_CTX *ctx, const char *prop,
PROPERTY_DEFN_ELEM elem, *old, *p = NULL;
size_t len;
LHASH_OF(PROPERTY_DEFN_ELEM) *property_defns;
+ int res = 1;
property_defns = ossl_lib_ctx_get_data(ctx,
OSSL_LIB_CTX_PROPERTY_DEFN_INDEX,
@@ -98,10 +101,12 @@ int ossl_prop_defn_set(OSSL_LIB_CTX *ctx, const char *prop,
if (prop == NULL)
return 1;
+ if (!ossl_lib_ctx_write_lock(ctx))
+ return 0;
if (pl == NULL) {
elem.prop = prop;
lh_PROPERTY_DEFN_ELEM_delete(property_defns, &elem);
- return 1;
+ goto end;
}
len = strlen(prop);
p = OPENSSL_malloc(sizeof(*p) + len);
@@ -112,11 +117,14 @@ int ossl_prop_defn_set(OSSL_LIB_CTX *ctx, const char *prop,
old = lh_PROPERTY_DEFN_ELEM_insert(property_defns, p);
if (old != NULL) {
property_defn_free(old);
- return 1;
+ goto end;
}
if (!lh_PROPERTY_DEFN_ELEM_error(property_defns))
- return 1;
+ goto end;
}
OPENSSL_free(p);
- return 0;
+ res = 0;
+ end:
+ ossl_lib_ctx_unlock(ctx);
+ return res;
}