From: Perttu Ahola Date: Wed, 1 Jun 2011 21:01:11 +0000 (+0300) Subject: Fixed the password crash on Windows X-Git-Tag: 0.2.20110731_3~154 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=51cf464f7450ee31e3a986b521f90cc6195bb2fb;p=oweals%2Fminetest.git Fixed the password crash on Windows --- 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 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 \""<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;