diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-06-02 00:01:11 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-06-02 00:01:11 +0300 |
commit | 51cf464f7450ee31e3a986b521f90cc6195bb2fb (patch) | |
tree | 8ba28ebba364d3505c946e987c2169912cc153c4 | |
parent | bbead93c1a00a1c31956e12c94717f179ac5b84b (diff) | |
download | minetest-51cf464f7450ee31e3a986b521f90cc6195bb2fb.tar.gz minetest-51cf464f7450ee31e3a986b521f90cc6195bb2fb.tar.bz2 minetest-51cf464f7450ee31e3a986b521f90cc6195bb2fb.zip |
Fixed the password crash on Windows
-rw-r--r-- | src/base64.cpp | 7 | ||||
-rw-r--r-- | src/client.cpp | 6 | ||||
-rw-r--r-- | src/main.cpp | 3 | ||||
-rw-r--r-- | src/server.cpp | 2 | ||||
-rw-r--r-- | src/utility.cpp | 8 |
5 files changed, 18 insertions, 8 deletions
diff --git a/src/base64.cpp b/src/base64.cpp index 2a863d161..0dfba5013 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -71,9 +71,10 @@ std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_ for (j = 0; (j < i + 1); j++) ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; + + // Don't pad it with = + /*while((i++ < 3)) + ret += '=';*/ } diff --git a/src/client.cpp b/src/client.cpp index 79bbd8021..e494056f2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -306,8 +306,14 @@ void Client::step(float dtime) SharedBuffer<u8> data(2+1+PLAYERNAME_SIZE+PASSWORD_SIZE); writeU16(&data[0], TOSERVER_INIT); writeU8(&data[2], SER_FMT_VER_HIGHEST); + memset((char*)&data[3], 0, PLAYERNAME_SIZE); snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName()); + + /*dstream<<"Client: password hash is \""<<m_password<<"\"" + <<std::endl;*/ + + memset((char*)&data[23], 0, PASSWORD_SIZE); snprintf((char*)&data[23], PASSWORD_SIZE, "%s", m_password.c_str()); // Send as unreliable diff --git a/src/main.cpp b/src/main.cpp index e582569c5..958f812b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -314,6 +314,7 @@ Fixes to the current release: -----------------------------
- Fix client password crash
- Remember to release the fixes (some are already done)
+- A command to set one's password when the server is running
Stuff to do after release:
---------------------------
@@ -1527,6 +1528,8 @@ int main(int argc, char *argv[]) g_settings.set("creative_mode", itos(menudata.creative_mode));
g_settings.set("enable_damage", itos(menudata.enable_damage));
+ // NOTE: These are now checked server side; no need to do it
+ // here, so let's not do it here.
/*// Check for valid parameters, restart menu if invalid.
if(playername == "")
{
diff --git a/src/server.cpp b/src/server.cpp index acfc7446f..96fcc0d07 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1923,7 +1923,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) checkpwd = g_settings.get("default_password"); } - if(password != checkpwd) + if(password != checkpwd && checkpwd != "") { derr_server<<DTIME<<"Server: peer_id="<<peer_id <<": supplied invalid password for " diff --git a/src/utility.cpp b/src/utility.cpp index 186881c5a..0721100cb 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -229,10 +229,10 @@ std::string translatePassword(std::string playername, std::wstring password) if(password.length() == 0) return ""; - std::string slt=playername + wide_to_narrow(password); - SHA1 *sha1 = new SHA1(); - sha1->addBytes(slt.c_str(), slt.length()); - unsigned char *digest = sha1->getDigest(); + std::string slt = playername + wide_to_narrow(password); + SHA1 sha1; + sha1.addBytes(slt.c_str(), slt.length()); + unsigned char *digest = sha1.getDigest(); std::string pwd = base64_encode(digest, 20); free(digest); return pwd; |