mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[8378] Use exceptions instead of explicit size checking for each packet
CHECK_PACKET_SIZE was pretty error prone; once it was forgotten mangosd could crash due to the asserts in ByteBuffer.h. That was exploitable by malicious players. Furthermore, there were duplicate checks: Additionally to CHECK_PACKET_SIZE, the ByteBuffer assertions keept an eye on not exceeding the packet boundaries - just to crash the server for sure in such a case. To prevent memory leaks or other undesirable states, please read in every handler all variables _before_ doing any concrete handling.
This commit is contained in:
parent
c26c7395a1
commit
a24f39a36f
32 changed files with 129 additions and 741 deletions
|
|
@ -39,8 +39,6 @@
|
|||
|
||||
void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,4+4+1);
|
||||
|
||||
uint32 type;
|
||||
uint32 lang;
|
||||
|
||||
|
|
@ -171,7 +169,6 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
|
|||
{
|
||||
std::string to, msg;
|
||||
recv_data >> to;
|
||||
CHECK_PACKET_SIZE(recv_data,4+4+(to.size()+1)+1);
|
||||
recv_data >> msg;
|
||||
|
||||
// strip invisible characters for non-addon messages
|
||||
|
|
@ -424,9 +421,6 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
|
|||
std::string channel = "", msg = "";
|
||||
recv_data >> channel;
|
||||
|
||||
// recheck
|
||||
CHECK_PACKET_SIZE(recv_data,4+4+(channel.size()+1)+1);
|
||||
|
||||
recv_data >> msg;
|
||||
|
||||
// strip invisible characters for non-addon messages
|
||||
|
|
@ -491,7 +485,6 @@ void WorldSession::HandleEmoteOpcode( WorldPacket & recv_data )
|
|||
{
|
||||
if(!GetPlayer()->isAlive())
|
||||
return;
|
||||
CHECK_PACKET_SIZE(recv_data,4);
|
||||
|
||||
uint32 emote;
|
||||
recv_data >> emote;
|
||||
|
|
@ -542,8 +535,6 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
|
|||
return;
|
||||
}
|
||||
|
||||
CHECK_PACKET_SIZE(recv_data,4+4+8);
|
||||
|
||||
uint32 text_emote, emoteNum;
|
||||
uint64 guid;
|
||||
|
||||
|
|
@ -593,8 +584,6 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+1);
|
||||
|
||||
uint64 iguid;
|
||||
uint8 unk;
|
||||
//sLog.outDebug("WORLD: Received CMSG_CHAT_IGNORED");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue