From: Fred Morcos Date: Tue, 10 Jan 2023 17:33:51 +0000 (+0100) Subject: libssl: Cleanup TLS engine loading X-Git-Tag: dnsdist-1.8.0-rc1~50^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=059d888015bec2e14aa0b1405deab3eecd9272da;p=thirdparty%2Fpdns.git libssl: Cleanup TLS engine loading --- diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 1103325708..3e3bdc9220 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -80,7 +80,7 @@ static void openssl_thread_cleanup() static std::atomic s_users; #ifndef OPENSSL_NO_ENGINE -static LockGuarded>> s_engines; +static LockGuarded>> s_engines; #endif static int s_ticketsKeyIndex{-1}; static int s_countersIndex{-1}; @@ -182,14 +182,11 @@ std::pair libssl_load_engine(const std::string& engineName, c return { false, "TLS engine already loaded" }; } - ENGINE* enginePtr = ENGINE_by_id(engineName.c_str()); - if (enginePtr == nullptr) { + auto engine = std::unique_ptr(ENGINE_by_id(engineName.c_str()), ENGINE_free); + if (engine == nullptr) { return { false, "unable to load TLS engine '" + engineName + "'" }; } - auto engine = std::unique_ptr(enginePtr, ENGINE_free); - enginePtr = nullptr; - if (!ENGINE_init(engine.get())) { return { false, "Unable to init TLS engine '" + engineName + "'" }; }