forked from mirror/openmw-tes3mp
[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
11 changed files with 46 additions and 22 deletions
|
@ -36,11 +36,16 @@ bool ActorProcessor::Process(RakNet::Packet &packet, BaseActorList &actorList) n
|
||||||
ActorPacket *myPacket = Networking::get().getActorPacketController()->GetPacket(packet.data[0]);
|
ActorPacket *myPacket = Networking::get().getActorPacketController()->GetPacket(packet.data[0]);
|
||||||
|
|
||||||
myPacket->setActorList(&actorList);
|
myPacket->setActorList(&actorList);
|
||||||
|
actorList.isValid = true;
|
||||||
|
|
||||||
if (!processor.second->avoidReading)
|
if (!processor.second->avoidReading)
|
||||||
myPacket->Read();
|
myPacket->Read();
|
||||||
|
|
||||||
|
if (actorList.isValid)
|
||||||
processor.second->Do(*myPacket, *player, actorList);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,17 @@ bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList)
|
||||||
myGuid = Main::get().getLocalPlayer()->guid;
|
myGuid = Main::get().getLocalPlayer()->guid;
|
||||||
request = packet.length == myPacket->headerSize();
|
request = packet.length == myPacket->headerSize();
|
||||||
|
|
||||||
|
actorList.isValid = true;
|
||||||
|
|
||||||
if (!request && !processor.second->avoidReading)
|
if (!request && !processor.second->avoidReading)
|
||||||
{
|
{
|
||||||
myPacket->Read();
|
myPacket->Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actorList.isValid)
|
||||||
processor.second->Do(*myPacket, actorList);
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ namespace mwmp
|
||||||
ESM::Cell cell;
|
ESM::Cell cell;
|
||||||
|
|
||||||
unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
|
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);
|
RW(actorList->count, send);
|
||||||
|
|
||||||
|
if (actorList->count > 2000)
|
||||||
|
{
|
||||||
|
actorList->isValid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RW(actorList->cell.mData.mFlags, send);
|
RW(actorList->cell.mData.mFlags, send);
|
||||||
RW(actorList->cell.mData.mX, send);
|
RW(actorList->cell.mData.mX, send);
|
||||||
RW(actorList->cell.mData.mY, 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.refNumIndex, send);
|
||||||
RW(actor.mpNum, send);
|
RW(actor.mpNum, send);
|
||||||
|
|
||||||
|
if (actor.refId.empty() || (actor.refNumIndex != 0 && actor.mpNum != 0))
|
||||||
|
{
|
||||||
|
actorList->isValid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
{
|
{
|
||||||
actorList->baseActors.push_back(actor);
|
actorList->baseActors.push_back(actor);
|
||||||
|
|
Loading…
Reference in a new issue