From 4b2bd2722b8294a6b27c9e1fcf7d76f7d9de9b44 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Wed, 13 Apr 2022 12:32:14 +0200 Subject: Public API functions OPENSSL_str[n]casecmp Reviewed-by: Tim Hudson Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18069) --- crypto/init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crypto/init.c') diff --git a/crypto/init.c b/crypto/init.c index b7d7ad0ea3..d859bd42c6 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -32,6 +32,7 @@ #include "crypto/store.h" #include /* for OSSL_CMP_log_close() */ #include +#include "crypto/ctype.h" static int stopped = 0; static uint64_t optsdone = 0; @@ -270,6 +271,15 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_async) return 1; } +static CRYPTO_ONCE casecmp = CRYPTO_ONCE_STATIC_INIT; +static int casecmp_inited = 0; +DEFINE_RUN_ONCE_STATIC(ossl_init_casecmp) +{ + int ret = ossl_init_casecmp_int(); + + casecmp_inited = 1; + return ret; +} #ifndef OPENSSL_NO_ENGINE static CRYPTO_ONCE engine_openssl = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(ossl_init_engine_openssl) @@ -387,6 +397,11 @@ void OPENSSL_cleanup(void) async_deinit(); } + if (casecmp_inited) { + OSSL_TRACE(INIT, "OPENSSL_cleanup: ossl_deinit_casecmp()\n"); + ossl_deinit_casecmp(); + } + if (load_crypto_strings_inited) { OSSL_TRACE(INIT, "OPENSSL_cleanup: err_free_strings_int()\n"); err_free_strings_int(); @@ -459,6 +474,9 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) { uint64_t tmp; int aloaddone = 0; + if (!RUN_ONCE(&casecmp, ossl_init_casecmp)) + return 0; + /* Applications depend on 0 being returned when cleanup was already done */ if (stopped) { -- cgit v1.2.3