mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-10-01 09:00:58 -04:00
[Server] Fix credentials generation. Used static variable as a workaround.
This commit is contained in:
parent
0206d1813c
commit
bf7041b067
@ -17,9 +17,10 @@ const char *MiscellaneousFunctions::GenerateRandomString(unsigned int length) no
|
|||||||
|
|
||||||
std::random_device randomDevice;
|
std::random_device randomDevice;
|
||||||
std::mt19937 generator(randomDevice());
|
std::mt19937 generator(randomDevice());
|
||||||
std::uniform_int_distribution<> distribution(0, characters.size() - 1);
|
std::uniform_int_distribution<std::mt19937::result_type> distribution(0, characters.size() - 1);
|
||||||
|
|
||||||
std::string randomString;
|
/* WARNING: this function is no longer reentrant with a static variable */
|
||||||
|
static std::string randomString;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < length; ++i)
|
for (std::size_t i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
@ -31,7 +32,8 @@ const char *MiscellaneousFunctions::GenerateRandomString(unsigned int length) no
|
|||||||
|
|
||||||
const char *MiscellaneousFunctions::GetSHA256Hash(const char* inputString) noexcept
|
const char *MiscellaneousFunctions::GetSHA256Hash(const char* inputString) noexcept
|
||||||
{
|
{
|
||||||
std::string hashString = picosha2::hash256_hex_string(std::string{inputString});
|
/* WARNING: this function is no longer reentrant with a static variable */
|
||||||
|
static std::string hashString = picosha2::hash256_hex_string(std::string{inputString});
|
||||||
|
|
||||||
return hashString.c_str();
|
return hashString.c_str();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the SHA256 hash corresponding to an input string.
|
* \brief Get the SHA256 hash corresponding to an input string.
|
||||||
|
* \details function is not reentrant due to a static variable
|
||||||
*
|
*
|
||||||
* \param inputString The input string.
|
* \param inputString The input string.
|
||||||
* \return The SHA256 hash.
|
* \return The SHA256 hash.
|
||||||
@ -36,6 +37,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the last player ID currently connected to the server.
|
* \brief Get the last player ID currently connected to the server.
|
||||||
|
* \details function is not reentrant due to a static variable
|
||||||
*
|
*
|
||||||
* Every player receives a unique numerical index known as their player ID upon joining the
|
* Every player receives a unique numerical index known as their player ID upon joining the
|
||||||
* server.
|
* server.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user