diff --git a/src/base64.cpp b/src/base64.cpp index 2a863d161a00e5fcf6c56caf0c088ef6914f1a9e..0dfba501303aa4606232c5f667f35f6ea895b86c 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 79bbd8021ca64ba60b2429e67b5ab9a8c4f37c8a..e494056f27dcaeaeb56b75e4082df1423a32012d 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 e582569c521548dcc3431d10e91036eaf49c3d37..958f812b3cc64b272f4a11ebba9577f75c334844 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 acfc7446f18fa6f12f59d8f14920c8086f6e3760..96fcc0d0757a1aa8a78dab959895c4d6b590aba7 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 186881c5acc2ba59a794301f457248a202a2a4d4..0721100cb98e845871e033aaf5920fcb9a624a14 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;