ignore empty chat messages

this could happen with a malicious client of some kind, we should simply
ignore them
This commit is contained in:
Lion Kortlepel 2022-10-31 02:32:58 +01:00
parent 4e8bd993d5
commit d36bb7962c
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -184,6 +184,10 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
if (ColonPos != std::string::npos && ColonPos + 2 < PacketAsString.size()) { if (ColonPos != std::string::npos && ColonPos + 2 < PacketAsString.size()) {
Message = PacketAsString.substr(ColonPos + 2); Message = PacketAsString.substr(ColonPos + 2);
} }
if (Message.empty()) {
beammp_debugf("Empty chat message received from '{}' ({}), ignoring it", LockedClient->GetName(), LockedClient->GetID());
return;
}
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onChatMessage", "", LockedClient->GetID(), LockedClient->GetName(), Message); auto Futures = LuaAPI::MP::Engine->TriggerEvent("onChatMessage", "", LockedClient->GetID(), LockedClient->GetName(), Message);
TLuaEngine::WaitForAll(Futures); TLuaEngine::WaitForAll(Futures);
LogChatMessage(LockedClient->GetName(), LockedClient->GetID(), PacketAsString.substr(PacketAsString.find(':', 3) + 1)); LogChatMessage(LockedClient->GetName(), LockedClient->GetID(), PacketAsString.substr(PacketAsString.find(':', 3) + 1));