Fixed problem of server always receiving an empty password from the client
authorPerttu Ahola <celeron55@gmail.com>
Sun, 31 Jul 2011 12:32:45 +0000 (15:32 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 31 Jul 2011 12:32:45 +0000 (15:32 +0300)
src/client.cpp
src/main.cpp
src/server.cpp

index 5f299890a34f72deec3729e0566248a7198cbe44..55f0af6dceda0b9a035aa0509eb5d9a5972ab148 100644 (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);
index 3cc7489541c1f56bc7a5681eafb4c0cc823df505..77340cab376836e26ac438a2be0af4b948c2df31 100644 (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)
index ba40ec6276332e98026fed071b77ac63ae2c75d0..35c186b5d339f77a2d4c67058db5aef01bd366fb 100644 (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)
@@ -3361,7 +3367,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                }
 
                std::string checkpwd = m_authmanager.getPassword(playername);
-               
+
                if(oldpwd != checkpwd)
                {
                        dstream<<"Server: invalid old password"<<std::endl;