diff --git a/dAuthServer/AuthServer.cpp b/dAuthServer/AuthServer.cpp index ddec32db..262886d7 100644 --- a/dAuthServer/AuthServer.cpp +++ b/dAuthServer/AuthServer.cpp @@ -171,6 +171,8 @@ dLogger* SetupLogger() { } void HandlePacket(Packet* packet) { + if (packet->length < 4) return; + if (packet->data[0] == ID_USER_PACKET_ENUM) { if (static_cast(packet->data[1]) == eConnectionType::SERVER) { if (static_cast(packet->data[3]) == eServerMessageType::VERSION_CONFIRM) { diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 3e3ddfd3..b9fb8556 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -203,6 +203,8 @@ void HandlePacket(Packet* packet) { Game::logger->Log("ChatServer", "A server is connecting, awaiting user list."); } + if (packet->length < 4) return; // Nothing left to process. Need 4 bytes to continue. + if (static_cast(packet->data[1]) == eConnectionType::CHAT_INTERNAL) { switch (static_cast(packet->data[3])) { case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION: diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 4b524d8d..bc0937c2 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -495,6 +495,8 @@ void HandlePacket(Packet* packet) { } } + if (packet->length < 4) return; + if (static_cast(packet->data[1]) == eConnectionType::MASTER) { switch (static_cast(packet->data[3])) { case eMasterMessageType::REQUEST_PERSISTENT_ID: { diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 4eca86f2..26cbe7ba 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -728,7 +728,7 @@ void HandlePacket(Packet* packet) { Game::server->SendToMaster(&bitStream); } - if (packet->data[0] != ID_USER_PACKET_ENUM) return; + if (packet->data[0] != ID_USER_PACKET_ENUM || packet->length < 4) return; if (static_cast(packet->data[1]) == eConnectionType::SERVER) { if (static_cast(packet->data[3]) == eServerMessageType::VERSION_CONFIRM) { AuthPackets::HandleHandshake(Game::server, packet);