Validate cookie data

This commit is contained in:
Gent 2020-09-12 11:41:31 -04:00
parent be99714495
commit 2b1a028b3d

View File

@ -29,14 +29,18 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
std::string userLogin((char*)login->szCookie_TEGid);
std::string userPassword((char*)login->szCookie_authid);
/*
* Sometimes the client sends garbage cookie data.
* Validate it as normal credentials instead of using a length check before falling back.
*/
if (!CNLoginServer::isLoginDataGood(userLogin, userPassword)) {
/*
* The std::string -> char* -> std::string maneuver should remove any
* trailing garbage after the null terminator.
*/
if (userLogin.length() == 0)
userLogin = std::string(U16toU8(login->szID).c_str());
if (userPassword.length() == 0)
userPassword = std::string(U16toU8(login->szPassword).c_str());
}
bool success = false;
int errorCode = 0;