Merge pull request #81 from gsemaj/auth

Validate cookie data
This commit is contained in:
dongresource 2020-09-12 18:03:26 +02:00 committed by GitHub
commit fe370df534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -30,13 +30,17 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
std::string userPassword((char*)login->szCookie_authid);
/*
* The std::string -> char* -> std::string maneuver should remove any
* trailing garbage after the null terminator.
*/
if (userLogin.length() == 0)
* 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.
*/
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;