diff options
author | est31 <MTest31@outlook.com> | 2015-09-30 00:38:05 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-09-30 09:19:40 +0200 |
commit | 0bf1984d2c9fb3a9dc73303551c18906c3c9482b (patch) | |
tree | 68e5bbcfd4914b2389c08947e2581e4c6c50f74f /src/util/auth.cpp | |
parent | 2a7d01b833da7b93125ad31e787f3e2145a22ec5 (diff) | |
download | minetest-0bf1984d2c9fb3a9dc73303551c18906c3c9482b.tar.gz minetest-0bf1984d2c9fb3a9dc73303551c18906c3c9482b.tar.bz2 minetest-0bf1984d2c9fb3a9dc73303551c18906c3c9482b.zip |
Fix some SRP issues
-> Remove memory allocation bugs
-> Merge changes from upstream, enabling customizeable memory allocation
Diffstat (limited to 'src/util/auth.cpp')
-rw-r--r-- | src/util/auth.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/util/auth.cpp b/src/util/auth.cpp index df8940e87..0c17a9237 100644 --- a/src/util/auth.cpp +++ b/src/util/auth.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "sha1.h" #include "srp.h" #include "string.h" +#include "debug.h" // Get an sha-1 hash of the player's name combined with // the password entered. That's what the server uses as @@ -50,10 +51,11 @@ void getSRPVerifier(const std::string &name, char **bytes_v, size_t *len_v) { std::string n_name = lowercase(name); - srp_create_salted_verification_key(SRP_SHA256, SRP_NG_2048, + SRP_Result res = srp_create_salted_verification_key(SRP_SHA256, SRP_NG_2048, n_name.c_str(), (const unsigned char *)password.c_str(), password.size(), (unsigned char **)salt, salt_len, (unsigned char **)bytes_v, len_v, NULL, NULL); + FATAL_ERROR_IF(res != SRP_OK, "Couldn't create salted SRP verifier"); } // Get a db-ready SRP verifier @@ -67,6 +69,7 @@ inline static std::string getSRPVerifier(const std::string &name, size_t len_v; getSRPVerifier(name, password, salt, &salt_len, &bytes_v, &len_v); + assert(*salt); // usually, srp_create_salted_verification_key promises us to return SRP_ERR when *salt == NULL std::string ret_val = encodeSRPVerifier(std::string(bytes_v, len_v), std::string(*salt, salt_len)); free(bytes_v); |