Critical BUGFIX: md5 bug
This commit is contained in:
parent
ce09673dcc
commit
a65c3d8c85
|
@ -193,30 +193,13 @@ void Server::processRequest(const QByteArray &msg) {
|
||||||
|
|
||||||
QJsonArray arr = String2Json(doc[3].toString()).array();
|
QJsonArray arr = String2Json(doc[3].toString()).array();
|
||||||
|
|
||||||
if (md5 != arr[2].toString()) {
|
handleNameAndPassword(client, arr[0].toString(), arr[1].toString(),
|
||||||
QJsonArray body;
|
arr[2].toString());
|
||||||
body << -2;
|
|
||||||
body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER |
|
|
||||||
Router::DEST_CLIENT);
|
|
||||||
body << "ErrorMsg";
|
|
||||||
body << "MD5 check failed!";
|
|
||||||
client->send(JsonArray2Bytes(body));
|
|
||||||
|
|
||||||
body.removeLast();
|
|
||||||
body.removeLast();
|
|
||||||
body << "UpdatePackage";
|
|
||||||
body << Pacman->getPackSummary();
|
|
||||||
client->send(JsonArray2Bytes(body));
|
|
||||||
|
|
||||||
client->disconnectFromHost();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleNameAndPassword(client, arr[0].toString(), arr[1].toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
|
void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
|
||||||
const QString &password) {
|
const QString &password,
|
||||||
|
const QString &md5_str) {
|
||||||
// First check the name and password
|
// First check the name and password
|
||||||
// Matches a string that does not contain special characters
|
// Matches a string that does not contain special characters
|
||||||
static QRegularExpression nameExp("['\";#]+|(--)|(/\\*)|(\\*/)|(--\\+)");
|
static QRegularExpression nameExp("['\";#]+|(--)|(/\\*)|(\\*/)|(--\\+)");
|
||||||
|
@ -236,6 +219,25 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString &name,
|
||||||
decrypted_pw = "\xFF";
|
decrypted_pw = "\xFF";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (md5 != md5_str) {
|
||||||
|
QJsonArray body;
|
||||||
|
body << -2;
|
||||||
|
body << (Router::TYPE_NOTIFICATION | Router::SRC_SERVER |
|
||||||
|
Router::DEST_CLIENT);
|
||||||
|
body << "ErrorMsg";
|
||||||
|
body << "MD5 check failed!";
|
||||||
|
client->send(JsonArray2Bytes(body));
|
||||||
|
|
||||||
|
body.removeLast();
|
||||||
|
body.removeLast();
|
||||||
|
body << "UpdatePackage";
|
||||||
|
body << Pacman->getPackSummary();
|
||||||
|
client->send(JsonArray2Bytes(body));
|
||||||
|
|
||||||
|
client->disconnectFromHost();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool passed = false;
|
bool passed = false;
|
||||||
QString error_msg;
|
QString error_msg;
|
||||||
QJsonArray result;
|
QJsonArray result;
|
||||||
|
|
|
@ -19,8 +19,8 @@ public:
|
||||||
bool listen(const QHostAddress &address = QHostAddress::Any,
|
bool listen(const QHostAddress &address = QHostAddress::Any,
|
||||||
ushort port = 9527u);
|
ushort port = 9527u);
|
||||||
|
|
||||||
void createRoom(ServerPlayer *owner, const QString &name,
|
void createRoom(ServerPlayer *owner, const QString &name, int capacity,
|
||||||
int capacity, const QByteArray &settings = "{}");
|
const QByteArray &settings = "{}");
|
||||||
|
|
||||||
Room *findRoom(int id) const;
|
Room *findRoom(int id) const;
|
||||||
Room *lobby() const;
|
Room *lobby() const;
|
||||||
|
@ -61,8 +61,8 @@ private:
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
QString md5;
|
QString md5;
|
||||||
|
|
||||||
void handleNameAndPassword(ClientSocket *client,
|
void handleNameAndPassword(ClientSocket *client, const QString &name,
|
||||||
const QString &name, const QString &password);
|
const QString &password, const QString &md5_str);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Server *ServerInstance;
|
extern Server *ServerInstance;
|
||||||
|
|
Loading…
Reference in New Issue