Fixed problem of server always receiving an empty password from the client

master
Perttu Ahola 2011-07-31 15:32:45 +03:00
parent bb77b1c0af
commit e0b8e66540
3 changed files with 12 additions and 4 deletions

View File

@ -424,7 +424,7 @@ void Client::step(float dtime)
memset((char*)&data[3], 0, PLAYERNAME_SIZE);
snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName());
/*dstream<<"Client: password hash is \""<<m_password<<"\""
/*dstream<<"Client: sending initial password hash: \""<<m_password<<"\""
<<std::endl;*/
memset((char*)&data[23], 0, PASSWORD_SIZE);

View File

@ -1583,6 +1583,8 @@ int main(int argc, char *argv[])
password = translatePassword(playername, menudata.password);
//dstream<<"Main: password hash: '"<<password<<"'"<<std::endl;
address = wide_to_narrow(menudata.address);
int newport = stoi(wide_to_narrow(menudata.port));
if(newport != 0)

View File

@ -2020,7 +2020,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Get password
char password[PASSWORD_SIZE];
if(datasize >= 2+1+PLAYERNAME_SIZE)
if(datasize < 2+1+PLAYERNAME_SIZE+PASSWORD_SIZE)
{
// old version - assume blank password
password[0] = 0;
@ -2044,7 +2044,10 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
checkpwd = g_settings.get("default_password");
}
if(password != checkpwd && checkpwd != "")
/*dstream<<"Server: Client gave password '"<<password
<<"', the correct one is '"<<checkpwd<<"'"<<std::endl;*/
if(password != checkpwd)
{
derr_server<<DTIME<<"Server: peer_id="<<peer_id
<<": supplied invalid password for "
@ -3350,6 +3353,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
newpwd += c;
}
dstream<<"Server: Client requests a password change from "
<<"'"<<oldpwd<<"' to '"<<newpwd<<"'"<<std::endl;
std::string playername = player->getName();
if(m_authmanager.exists(playername) == false)