fix empty events causing issues in the server

an empty event packet, if sent just right, could crash the server
This commit is contained in:
Lion Kortlepel 2022-10-31 02:34:26 +01:00
parent 5581fd1692
commit b10d5d0f4e
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -222,6 +222,10 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
void TServer::HandleEvent(TClient& c, const std::string& RawData) {
// E:Name:Data
// Data is allowed to have ':'
if (RawData.size() < 2) {
beammp_debugf("Client '{}' ({}) tried to send an empty event, ignoring", c.GetName(), c.GetID());
return;
}
auto NameDataSep = RawData.find(':', 2);
if (NameDataSep == std::string::npos) {
beammp_warn("received event in invalid format (missing ':'), got: '" + RawData + "'");