forked from mirror/openmw-tes3mp
[General] Add integrity checks to Handshake packet
This commit is contained in:
parent
f9ff5f10df
commit
1f4e6e9114
3 changed files with 17 additions and 2 deletions
|
@ -99,6 +99,13 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
|||
myPacket->setPlayer(player);
|
||||
myPacket->Read();
|
||||
|
||||
if (!myPacket->isPacketValid())
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Invalid handshake packet from %d", player->getId());
|
||||
kickPlayer(player->guid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->isHandshaked())
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with player %d, name: %s", player->getId(),
|
||||
|
|
|
@ -16,6 +16,11 @@ PacketHandshake::PacketHandshake(RakNet::RakPeerInterface *peer) : PlayerPacket(
|
|||
void PacketHandshake::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
RW(player->npc.mName, send);
|
||||
RW(player->passw, send);
|
||||
|
||||
if (!RW(player->npc.mName, send, true, maxNameLen) ||
|
||||
!RW(player->passw, send, true, maxPasswLen))
|
||||
{
|
||||
packetValid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace mwmp
|
|||
PacketHandshake(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
|
||||
const static uint32_t maxNameLen = 256;
|
||||
const static uint32_t maxPasswLen = 256;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue