aboutsummaryrefslogtreecommitdiff
path: root/crypto/property
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2022-04-25 07:22:27 +0200
committerRichard Levitte <levitte@openssl.org>2022-05-05 15:14:37 +0200
commit106f5c231ccf7103564c8f81f169e372c444351b (patch)
tree0650a22bbede93947779edcfa7b3539ef5e0a374 /crypto/property
parent215708c53bc3d62fd29ec842d80fa929910178ee (diff)
downloadopenssl-106f5c231ccf7103564c8f81f169e372c444351b.zip
openssl-106f5c231ccf7103564c8f81f169e372c444351b.tar.gz
openssl-106f5c231ccf7103564c8f81f169e372c444351b.tar.bz2
Complete the cleanup of an algorithm in OSSL_METHOD_STORE
The `alg_cleanup` didn't properly clear the OPENSSL_SA leaf that it had just freed the contents of. Fortunately, `ossl_sa_ALGORITHM_doall_arg()` allows us to pass the store pointer itself as an extra argument, which allows a modified `alg_cleanup` to complete the job. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18151) (cherry picked from commit 03454ba2a234197c961920f1bac37cc9f4cf3f54)
Diffstat (limited to 'crypto/property')
-rw-r--r--crypto/property/property.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/crypto/property/property.c b/crypto/property/property.c
index 93d12af..83f49d9 100644
--- a/crypto/property/property.c
+++ b/crypto/property/property.c
@@ -213,14 +213,18 @@ static void impl_cache_flush_alg(ossl_uintmax_t idx, ALGORITHM *alg)
lh_QUERY_flush(alg->cache);
}
-static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a)
+static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a, void *arg)
{
+ OSSL_METHOD_STORE *store = arg;
+
if (a != NULL) {
sk_IMPLEMENTATION_pop_free(a->impls, &impl_free);
lh_QUERY_doall(a->cache, &impl_cache_free);
lh_QUERY_free(a->cache);
OPENSSL_free(a);
}
+ if (store != NULL)
+ ossl_sa_ALGORITHM_set(store->algs, idx, NULL);
}
/*
@@ -250,7 +254,7 @@ OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx)
void ossl_method_store_free(OSSL_METHOD_STORE *store)
{
if (store != NULL) {
- ossl_sa_ALGORITHM_doall(store->algs, &alg_cleanup);
+ ossl_sa_ALGORITHM_doall_arg(store->algs, &alg_cleanup, store);
ossl_sa_ALGORITHM_free(store->algs);
CRYPTO_THREAD_lock_free(store->lock);
OPENSSL_free(store);
@@ -340,7 +344,7 @@ int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
err:
ossl_property_unlock(store);
- alg_cleanup(0, alg);
+ alg_cleanup(0, alg, NULL);
impl_free(impl);
return 0;
}