mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[General] Add basic integrity checks to all Actor and World packets
This commit is contained in:
parent
e042673779
commit
d0a0b6ffa4
32 changed files with 172 additions and 11 deletions
|
@ -24,7 +24,7 @@ namespace mwmp
|
|||
|
||||
protected:
|
||||
BaseActorList *actorList;
|
||||
|
||||
static const int maxActors = 3000;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorAI::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorAnimFlags::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorAnimPlay::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorAttack::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -11,11 +11,4 @@ PacketActorAuthority::PacketActorAuthority(RakNet::RakPeerInterface *peer) : Act
|
|||
void PacketActorAuthority::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
ActorPacket::Packet(bs, send);
|
||||
|
||||
if (send)
|
||||
actorList->count = (unsigned int)(actorList->baseActors.size());
|
||||
else
|
||||
actorList->baseActors.clear();
|
||||
|
||||
RW(actorList->count, send);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorCellChange::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorDeath::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorEquipment::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -21,7 +21,7 @@ void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > 2000)
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorPosition::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorSpeech::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -21,6 +21,12 @@ void PacketActorStatsDynamic::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -20,6 +20,12 @@ void PacketActorTest::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > maxActors)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
|
|
|
@ -22,6 +22,12 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
@ -46,7 +52,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(worldObject.mpNum, send);
|
||||
RW(worldObject.containerItemCount, send);
|
||||
|
||||
if (worldObject.containerItemCount > 2000 || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
|
||||
if (worldObject.containerItemCount > maxObjects || worldObject.refId.empty() || (worldObject.refNumIndex != 0 && worldObject.mpNum != 0))
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketDoorState::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketMusicPlay::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
WorldObject worldObject;
|
||||
|
||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectAnimPlay::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectDelete::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectLock::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectMove::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectRotate::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectScale::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectSpawn::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketObjectTrap::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketScriptGlobalShort::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
WorldObject worldObject;
|
||||
|
||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketScriptLocalFloat::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketScriptLocalShort::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketScriptMemberShort::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
WorldObject worldObject;
|
||||
|
||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||
|
|
|
@ -19,6 +19,12 @@ void PacketVideoPlay::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(event->worldObjectCount, send);
|
||||
|
||||
if (event->worldObjectCount > maxObjects)
|
||||
{
|
||||
event->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
WorldObject worldObject;
|
||||
|
||||
for (unsigned int i = 0; i < event->worldObjectCount; i++)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace mwmp
|
|||
|
||||
protected:
|
||||
BaseEvent *event;
|
||||
|
||||
static const int maxObjects = 3000;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue