Disconnect when we get map change with invalid parameters

This is the only sane thing we can do, the server will have changed its
map and we can't pretend to still be on the old one.
This commit is contained in:
heinrich5991 2024-03-11 17:50:12 +01:00
parent 3489131d78
commit dd5ddf07a4

View file

@ -1372,15 +1372,21 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
const char *pMap = Unpacker.GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES);
int MapCrc = Unpacker.GetInt();
int MapSize = Unpacker.GetInt();
if(Unpacker.Error() || MapSize < 0)
if(Unpacker.Error())
{
return;
}
if(MapSize < 0 || MapSize > 1024 * 1024 * 1024) // 1 GiB
{
DisconnectWithReason("invalid map size");
return;
}
for(int i = 0; pMap[i]; i++) // protect the player from nasty map names
{
if(pMap[i] == '/' || pMap[i] == '\\')
{
DisconnectWithReason("strange character in map name");
return;
}
}