[General] Add basic integrity check to reading of ActorList packets

Additionally, add newlines to files missing them.
0.6.1
David Cernat 8 years ago
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();
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;
}
}

@ -28,12 +28,17 @@ bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList)
myGuid = Main::get().getLocalPlayer()->guid;
request = packet.length == myPacket->headerSize();
actorList.isValid = true;
if (!request && !processor.second->avoidReading)
{
myPacket->Read();
}
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;
}

@ -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…
Cancel
Save