Don’t use global static members but functions that return a reference to an internal static object

See https://github.com/randombit/botan/issues/761
This commit is contained in:
louiz’
2016-12-08 21:26:42 +01:00
parent 7f2eb60737
commit e1e740e35e
2 changed files with 20 additions and 13 deletions
+20 -6
View File
@@ -15,10 +15,24 @@
# include <botan/hex.h>
# include <botan/tls_exceptn.h>
Botan::AutoSeeded_RNG TCPSocketHandler::rng;
BiboumiTLSPolicy TCPSocketHandler::policy;
Botan::TLS::Session_Manager_In_Memory TCPSocketHandler::session_manager(TCPSocketHandler::rng);
namespace
{
Botan::AutoSeeded_RNG& get_rng()
{
static Botan::AutoSeeded_RNG rng{};
return rng;
}
BiboumiTLSPolicy& get_policy()
{
static BiboumiTLSPolicy policy{};
return policy;
}
Botan::TLS::Session_Manager_In_Memory& get_session_manager()
{
static Botan::TLS::Session_Manager_In_Memory session_manager{get_rng()};
return session_manager;
}
}
#endif
#ifndef UIO_FASTIOV
@@ -229,8 +243,8 @@ void TCPSocketHandler::start_tls(const std::string& address, const std::string&
[this](Botan::TLS::Alert alert, const Botan::byte*, size_t) { this->tls_alert(alert); },
[this](const Botan::TLS::Session& session) { return this->tls_session_established(session); },
# endif
session_manager, this->credential_manager, policy,
rng, server_info, Botan::TLS::Protocol_Version::latest_tls_version());
get_session_manager(), this->credential_manager, get_policy(),
get_rng(), server_info, Botan::TLS::Protocol_Version::latest_tls_version());
}
void TCPSocketHandler::tls_recv()