mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 23:51:09 -04:00
[General] Add basic integrity check to reading of ActorList packets
Additionally, add newlines to files missing them.
This commit is contained in:
parent
252a28fe24
commit
f527fe9ebe
@ -36,11 +36,16 @@ bool ActorProcessor::Process(RakNet::Packet &packet, BaseActorList &actorList) n
|
||||
ActorPacket *myPacket = Networking::get().getActorPacketController()->GetPacket(packet.data[0]);
|
||||
|
||||
myPacket->setActorList(&actorList);
|
||||
actorList.isValid = true;
|
||||
|
||||
if (!processor.second->avoidReading)
|
||||
myPacket->Read();
|
||||
|
||||
processor.second->Do(*myPacket, *player, actorList);
|
||||
if (actorList.isValid)
|
||||
processor.second->Do(*myPacket, *player, actorList);
|
||||
else
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -22,22 +22,27 @@ bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList)
|
||||
myPacket->SetReadStream(&bsIn);
|
||||
|
||||
BOOST_FOREACH(processors_t::value_type &processor, processors)
|
||||
{
|
||||
if (processor.first == packet.data[0])
|
||||
{
|
||||
myGuid = Main::get().getLocalPlayer()->guid;
|
||||
request = packet.length == myPacket->headerSize();
|
||||
{
|
||||
if (processor.first == packet.data[0])
|
||||
{
|
||||
myGuid = Main::get().getLocalPlayer()->guid;
|
||||
request = packet.length == myPacket->headerSize();
|
||||
|
||||
if (!request && !processor.second->avoidReading)
|
||||
{
|
||||
myPacket->Read();
|
||||
}
|
||||
actorList.isValid = true;
|
||||
|
||||
processor.second->Do(*myPacket, actorList);
|
||||
if (!request && !processor.second->avoidReading)
|
||||
{
|
||||
myPacket->Read();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (actorList.isValid)
|
||||
processor.second->Do(*myPacket, actorList);
|
||||
else
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ namespace mwmp
|
||||
ESM::Cell cell;
|
||||
|
||||
unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
|
||||
|
||||
bool isValid;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,12 @@ void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
|
||||
|
||||
RW(actorList->count, send);
|
||||
|
||||
if (actorList->count > 2000)
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
RW(actorList->cell.mData.mFlags, send);
|
||||
RW(actorList->cell.mData.mX, send);
|
||||
RW(actorList->cell.mData.mY, send);
|
||||
@ -43,6 +49,12 @@ void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
|
||||
if (actor.refId.empty() || (actor.refNumIndex != 0 && actor.mpNum != 0))
|
||||
{
|
||||
actorList->isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!send)
|
||||
{
|
||||
actorList->baseActors.push_back(actor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user