From a24f39a36f2b48ed2b04646e7817d17a20605d15 Mon Sep 17 00:00:00 2001 From: arrai Date: Sat, 15 Aug 2009 22:06:35 +0200 Subject: [PATCH] [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. --- src/game/ArenaTeamHandler.cpp | 16 ----- src/game/AuctionHouseHandler.cpp | 17 ------ src/game/BattleGroundHandler.cpp | 18 ------ src/game/ChannelHandler.cpp | 68 --------------------- src/game/CharacterHandler.cpp | 38 ------------ src/game/ChatHandler.cpp | 11 ---- src/game/CombatHandler.cpp | 4 -- src/game/DuelHandler.cpp | 4 -- src/game/GMTicketHandler.cpp | 11 ---- src/game/GroupHandler.cpp | 31 ---------- src/game/GuildHandler.cpp | 46 -------------- src/game/ItemHandler.cpp | 45 -------------- src/game/LFGHandler.cpp | 10 --- src/game/LootHandler.cpp | 8 --- src/game/Mail.cpp | 30 --------- src/game/MiscHandler.cpp | 95 +---------------------------- src/game/MovementHandler.cpp | 14 ----- src/game/NPCHandler.cpp | 30 --------- src/game/PetHandler.cpp | 23 ------- src/game/PetitionsHandler.cpp | 22 ------- src/game/QueryHandler.cpp | 10 --- src/game/QuestHandler.cpp | 26 -------- src/game/SkillHandler.cpp | 10 --- src/game/SpellHandler.cpp | 22 ------- src/game/TaxiHandler.cpp | 13 ---- src/game/TradeHandler.cpp | 8 --- src/game/WorldSession.cpp | 97 +++++++++++++++-------------- src/game/WorldSession.h | 2 - src/game/WorldSocket.cpp | 101 ++++++++++++++----------------- src/realmd/AuthSocket.cpp | 1 + src/shared/ByteBuffer.h | 37 +++++++---- src/shared/revision_nr.h | 2 +- 32 files changed, 129 insertions(+), 741 deletions(-) diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index 1c5ec74eb..ce5dda707 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -30,8 +30,6 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data) { sLog.outDebug("MSG_INSPECT_ARENA_TEAMS"); - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; sLog.outDebug("Inspect Arena stats (GUID: %u TypeId: %u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid))); @@ -53,8 +51,6 @@ void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket & recv_data) { sLog.outDebug( "WORLD: Received CMSG_ARENA_TEAM_QUERY" ); - CHECK_PACKET_SIZE(recv_data, 4); - uint32 ArenaTeamId; recv_data >> ArenaTeamId; @@ -70,8 +66,6 @@ void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data) { sLog.outDebug( "WORLD: Received CMSG_ARENA_TEAM_ROSTER" ); - CHECK_PACKET_SIZE(recv_data, 4); - uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; @@ -86,8 +80,6 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_INVITE"); - CHECK_PACKET_SIZE(recv_data, 4+1); - uint32 ArenaTeamId; // arena team id std::string Invitedname; @@ -205,8 +197,6 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_LEAVE"); - CHECK_PACKET_SIZE(recv_data, 4); - uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; @@ -242,8 +232,6 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_DISBAND"); - CHECK_PACKET_SIZE(recv_data, 4); - uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; @@ -265,8 +253,6 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_REMOVE"); - CHECK_PACKET_SIZE(recv_data, 4+1); - uint32 ArenaTeamId; std::string name; @@ -311,8 +297,6 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data) { sLog.outDebug("CMSG_ARENA_TEAM_LEADER"); - CHECK_PACKET_SIZE(recv_data, 4+1); - uint32 ArenaTeamId; std::string name; diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index f65b863ad..d1ccc19f3 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -33,8 +33,6 @@ //void called when player click on auctioneer npc void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; //NPC guid recv_data >> guid; @@ -151,8 +149,6 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction ) //this void creates new auction and adds auction to some auctionhouse void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+8+4+4+4); - uint64 auctioneer, item; uint32 etime, bid, buyout; recv_data >> auctioneer >> item; @@ -275,8 +271,6 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) //this function is called when client bids or buys out auction void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - uint64 auctioneer; uint32 auctionId; uint32 price; @@ -404,8 +398,6 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) //this void is called when auction_owner cancels his auction void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 auctioneer; uint32 auctionId; recv_data >> auctioneer; @@ -482,8 +474,6 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) //called when player lists his bids void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - uint64 guid; //NPC guid uint32 listfrom; //page of auctions uint32 outbiddedCount; //count of outbidded auctions @@ -538,8 +528,6 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) //this void sends player info about his auctions void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint32 listfrom; uint64 guid; @@ -575,8 +563,6 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) //this void is called when player clicks on search button void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1); - std::string searchedname; uint8 levelmin, levelmax, usable; uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; @@ -586,9 +572,6 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) recv_data >> listfrom; // start, used for page control listing by 50 elements recv_data >> searchedname; - // recheck with known string size - CHECK_PACKET_SIZE(recv_data,8+4+(searchedname.size()+1)+1+1+4+4+4+4+1); - recv_data >> levelmin >> levelmax; recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory; recv_data >> quality >> usable; diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 152221e2f..181dcfd08 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -34,8 +34,6 @@ void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid))); @@ -71,8 +69,6 @@ void WorldSession::SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgType void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4+4+1); - uint64 guid; uint32 bgTypeId_; uint32 instanceId; @@ -275,8 +271,6 @@ void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4 + 1); - sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message"); uint32 bgTypeId; @@ -299,8 +293,6 @@ void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data ) void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1+1+4+2+1); - sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message"); uint8 type; // arenatype if arena @@ -495,8 +487,6 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket & /*recv_data*/ ) { - //CHECK_PACKET_SIZE(recv_data, 1+1+4+2); - sLog.outDebug( "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message"); //uint8 unk1, unk2; @@ -579,8 +569,6 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY"); - CHECK_PACKET_SIZE(recv_data, 8); - BattleGround *bg = _player->GetBattleGround(); if (!bg) return; @@ -602,8 +590,6 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE"); - CHECK_PACKET_SIZE(recv_data, 8); - BattleGround *bg = _player->GetBattleGround(); if (!bg) return; @@ -623,8 +609,6 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+1+1+1); - sLog.outDebug("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA"); recv_data.hexlike(); @@ -778,8 +762,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 playerGuid; recv_data >> playerGuid; Player *reportedPlayer = objmgr.GetPlayer(playerGuid); diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp index 59e40a60a..a2d28f2e1 100644 --- a/src/game/ChannelHandler.cpp +++ b/src/game/ChannelHandler.cpp @@ -22,8 +22,6 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); - //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 4+1+1+1); uint32 channel_id; uint8 unknown1, unknown2; @@ -35,9 +33,6 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) if(channelname.empty()) return; - // recheck - CHECK_PACKET_SIZE(recvPacket, 4+1+1+(channelname.size()+1)+1); - recvPacket >> pass; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetJoinChannel(channelname, channel_id)) @@ -48,7 +43,6 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 4+1); uint32 unk; std::string channelname; @@ -70,8 +64,6 @@ void WorldSession::HandleChannelList(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; @@ -84,14 +76,9 @@ void WorldSession::HandleChannelPassword(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, pass; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> pass; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -103,14 +90,9 @@ void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, newp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> newp; if(!normalizePlayerName(newp)) @@ -125,8 +107,6 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -138,14 +118,9 @@ void WorldSession::HandleChannelModerator(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -160,14 +135,9 @@ void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -182,14 +152,9 @@ void WorldSession::HandleChannelMute(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -204,14 +169,10 @@ void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -226,14 +187,9 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -248,14 +204,9 @@ void WorldSession::HandleChannelKick(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) return; @@ -269,14 +220,9 @@ void WorldSession::HandleChannelBan(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); - std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -291,14 +237,10 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1+1); std::string channelname, otp; recvPacket >> channelname; - // recheck - CHECK_PACKET_SIZE(recvPacket, (channelname.size()+1)+1); - recvPacket >> otp; if(!normalizePlayerName(otp)) @@ -313,8 +255,6 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -326,8 +266,6 @@ void WorldSession::HandleChannelModerate(WorldPacket& recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -339,8 +277,6 @@ void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -352,8 +288,6 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) @@ -373,8 +307,6 @@ void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket) { sLog.outDebug("Opcode %u", recvPacket.GetOpcode()); //recvPacket.hexlike(); - CHECK_PACKET_SIZE(recvPacket, 1); - std::string channelname; recvPacket >> channelname; /*if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 98d6d068e..4ec092edb 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -178,16 +178,11 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1+1+1+1+1+1+1+1+1); - std::string name; uint8 race_,class_; recv_data >> name; - // recheck with known string size - CHECK_PACKET_SIZE(recv_data,(name.size()+1)+1+1+1+1+1+1+1+1+1); - recv_data >> race_; recv_data >> class_; @@ -472,8 +467,6 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -534,8 +527,6 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data ) void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - if(PlayerLoading() || GetPlayer() != NULL) { sLog.outError("Player tryes to login again, AccountId = %d",GetAccountId()); @@ -799,8 +790,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) void WorldSession::HandleSetFactionAtWar( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+1); - DEBUG_LOG( "WORLD: Received CMSG_SET_FACTION_ATWAR" ); uint32 repListID; @@ -815,8 +804,6 @@ void WorldSession::HandleSetFactionAtWar( WorldPacket & recv_data ) //I think this function is never used :/ I dunno, but i guess this opcode not exists void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ ) { - //CHECK_PACKET_SIZE(recv_data,4+4); - sLog.outError("WORLD SESSION: HandleSetFactionCheat, not expected call, please report."); /* uint32 FactionID; @@ -849,8 +836,6 @@ void WorldSession::HandleMeetingStoneInfo( WorldPacket & /*recv_data*/ ) void WorldSession::HandleTutorialFlag( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 iFlag; recv_data >> iFlag; @@ -883,8 +868,6 @@ void WorldSession::HandleTutorialReset( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - DEBUG_LOG("WORLD: Received CMSG_SET_WATCHED_FACTION"); uint32 fact; recv_data >> fact; @@ -893,8 +876,6 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data) void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4+1); - DEBUG_LOG("WORLD: Received CMSG_SET_FACTION_INACTIVE"); uint32 replistid; uint8 inactive; @@ -917,8 +898,6 @@ void WorldSession::HandleShowingCloakOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+1); - uint64 guid; std::string newname; @@ -1003,7 +982,6 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) { uint64 guid; - CHECK_PACKET_SIZE(recv_data, 8); recv_data >> guid; // not accept declined names for unsupported languages @@ -1039,7 +1017,6 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) std::string name2; DeclinedName declinedname; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> name2; if(name2 != name) // character have different name @@ -1053,7 +1030,6 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> declinedname.name[i]; if(!normalizePlayerName(declinedname.name[i])) { @@ -1093,8 +1069,6 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data ) { sLog.outDebug("CMSG_ALTER_APPEARANCE"); - CHECK_PACKET_SIZE(recv_data, 4+4+4); - uint32 Hair, Color, FacialHair; recv_data >> Hair >> Color >> FacialHair; @@ -1141,8 +1115,6 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data ) void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - uint32 slot; recv_data >> slot; @@ -1165,16 +1137,12 @@ void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data ) void WorldSession::HandleCharCustomize(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+1); - uint64 guid; std::string newname; recv_data >> guid; recv_data >> newname; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1+1+1+1+1); - uint8 gender, skin, face, hairStyle, hairColor, facialHair; recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face; @@ -1267,18 +1235,14 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data) if(!recv_data.readPackGUID(setGuid)) return; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 4); - uint32 index; recv_data >> index; if(index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount return; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); std::string name; recv_data >> name; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); std::string iconName; recv_data >> iconName; @@ -1331,8 +1295,6 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data) if(!recv_data.readPackGUID(itemGuid)) return; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1); - uint8 srcbag, srcslot; recv_data >> srcbag >> srcslot; diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index eaf993f50..a6c4f8f8d 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -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"); diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp index ddc6748e2..60eb32a3d 100644 --- a/src/game/CombatHandler.cpp +++ b/src/game/CombatHandler.cpp @@ -26,8 +26,6 @@ void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -74,8 +72,6 @@ void WorldSession::HandleAttackStopOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 sheathed; recv_data >> sheathed; diff --git a/src/game/DuelHandler.cpp b/src/game/DuelHandler.cpp index e9e1fa0b6..0fa58ea2b 100644 --- a/src/game/DuelHandler.cpp +++ b/src/game/DuelHandler.cpp @@ -26,8 +26,6 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8); - uint64 guid; Player *pl; Player *plTarget; @@ -59,8 +57,6 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8); - //sLog.outDebug( "WORLD: received CMSG_DUEL_CANCELLED" ); // no duel requested diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp index 8a36ff9dd..b046a69c8 100644 --- a/src/game/GMTicketHandler.cpp +++ b/src/game/GMTicketHandler.cpp @@ -59,8 +59,6 @@ void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); - std::string ticketText; recv_data >> ticketText; @@ -83,8 +81,6 @@ void WorldSession::HandleGMTicketDeleteTicketOpcode( WorldPacket & /*recv_data*/ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4); - uint32 map; float x, y, z; std::string ticketText = ""; @@ -93,9 +89,6 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) recv_data >> map >> x >> y >> z; // last check 2.4.3 recv_data >> ticketText; - // recheck - CHECK_PACKET_SIZE(recv_data,4*4+(ticketText.size()+1)+2*4); - recv_data >> unk1 >> unk2; // note: the packet might contain more data, but the exact structure of that is unknown @@ -141,7 +134,6 @@ void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data) { // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3 - CHECK_PACKET_SIZE(recv_data, 4+4); uint32 x; recv_data >> x; // answer range? (6 = 0-5?) sLog.outDebug("SURVEY: X = %u", x); @@ -150,13 +142,11 @@ void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data) memset(result, 0, sizeof(result)); for( int i = 0; i < 10; ++i) { - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+4); uint32 questionID; recv_data >> questionID; // GMSurveyQuestions.dbc if (!questionID) break; - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1+1); uint8 value; std::string unk_text; recv_data >> value; // answer @@ -166,7 +156,6 @@ void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data) sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str()); } - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1); std::string comment; recv_data >> comment; // addional comment sLog.outDebug("SURVEY: comment %s", comment.c_str()); diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index fc3a1f863..be879762f 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -220,8 +220,6 @@ void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -260,8 +258,6 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,1); - std::string membername; recv_data >> membername; @@ -304,8 +300,6 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - Group *group = GetPlayer()->GetGroup(); if(!group) return; @@ -346,8 +340,6 @@ void WorldSession::HandleGroupDisbandOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleLootMethodOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8+4); - Group *group = GetPlayer()->GetGroup(); if(!group) return; @@ -371,8 +363,6 @@ void WorldSession::HandleLootMethodOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootRoll( WorldPacket &recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+1); - if(!GetPlayer()->GetGroup()) return; @@ -405,8 +395,6 @@ void WorldSession::HandleLootRoll( WorldPacket &recv_data ) void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,4+4); - if(!GetPlayer()->GetGroup()) return; @@ -429,8 +417,6 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,4+4); - uint32 minimum, maximum, roll; recv_data >> minimum; recv_data >> maximum; @@ -458,8 +444,6 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); - Group *group = GetPlayer()->GetGroup(); if(!group) return; @@ -477,9 +461,6 @@ void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ) } else // target icon update { - // recheck - CHECK_PACKET_SIZE(recv_data,1+8); - if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) return; @@ -510,8 +491,6 @@ void WorldSession::HandleGroupRaidConvertOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1); - // we will get correct pointer for group here, so we don't have to check if group is BG raid Group *group = GetPlayer()->GetGroup(); if(!group) @@ -521,9 +500,6 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) uint8 groupNr; recv_data >> name; - // recheck - CHECK_PACKET_SIZE(recv_data,(name.size()+1)+1); - recv_data >> groupNr; /** error handling **/ @@ -540,8 +516,6 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+1); - Group *group = GetPlayer()->GetGroup(); if(!group) return; @@ -562,7 +536,6 @@ void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ) void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1+1+8); sLog.outDebug("MSG_PARTY_ASSIGNMENT"); Group *group = GetPlayer()->GetGroup(); @@ -797,8 +770,6 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS"); uint64 Guid; recv_data >> Guid; @@ -900,8 +871,6 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ) void WorldSession::HandleOptOutOfLootOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - sLog.outDebug("WORLD: Received CMSG_OPT_OUT_OF_LOOT"); uint32 unkn; diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 649f57b6e..26bb22a35 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -29,8 +29,6 @@ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 4); - uint32 guildId; Guild *guild; @@ -50,8 +48,6 @@ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string gname; //sLog.outDebug("WORLD: Received CMSG_GUILD_CREATE"); @@ -73,8 +69,6 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string Invitedname, plname; //sLog.outDebug("WORLD: Received CMSG_GUILD_INVITE"); @@ -146,8 +140,6 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string plName; //sLog.outDebug("WORLD: Received CMSG_GUILD_REMOVE"); @@ -269,8 +261,6 @@ void WorldSession::HandleGuildRosterOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string plName; //sLog.outDebug("WORLD: Received CMSG_GUILD_PROMOTE"); @@ -327,8 +317,6 @@ void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string plName; //sLog.outDebug("WORLD: Received CMSG_GUILD_DEMOTE"); @@ -451,8 +439,6 @@ void WorldSession::HandleGuildDisbandOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string name; Player *oldLeader = GetPlayer(); Guild *guild; @@ -537,8 +523,6 @@ void WorldSession::HandleGuildMOTDOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string name,PNOTE; //sLog.outDebug("WORLD: Received CMSG_GUILD_SET_PUBLIC_NOTE"); @@ -579,8 +563,6 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - std::string plName, OFFNOTE; //sLog.outDebug("WORLD: Received CMSG_GUILD_SET_OFFICER_NOTE"); @@ -620,7 +602,6 @@ void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 4+4+1+4*13); //recvPacket.hexlike(); Guild *guild; @@ -672,8 +653,6 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - Guild *guild; std::string rankname; @@ -742,8 +721,6 @@ void WorldSession::SendGuildCommandResult(uint32 typecmd, const std::string& str void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - //sLog.outDebug("WORLD: Received CMSG_GUILD_INFO_TEXT"); std::string GINFO; @@ -768,8 +745,6 @@ void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket) void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 8+4+4+4+4+4); - //sLog.outDebug("WORLD: Received MSG_SAVE_GUILD_EMBLEM"); uint64 vendorGuid; @@ -900,7 +875,6 @@ void WorldSession::HandleGuildPermissions( WorldPacket& /* recv_data */ ) void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)"); - CHECK_PACKET_SIZE(recv_data,8+1); uint64 GoGuid; uint8 unk; recv_data >> GoGuid >> unk; @@ -924,7 +898,6 @@ void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data ) void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)"); - CHECK_PACKET_SIZE(recv_data,8+1+1); uint64 GoGuid; uint8 TabId,unk1; recv_data >> GoGuid >> TabId >> unk1; @@ -950,7 +923,6 @@ void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data ) void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)"); - CHECK_PACKET_SIZE(recv_data,8+4); uint64 GoGuid; uint32 money; recv_data >> GoGuid >> money; @@ -998,7 +970,6 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data ) void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)"); - CHECK_PACKET_SIZE(recv_data,8+4); uint64 GoGuid; uint32 money; recv_data >> GoGuid >> money; @@ -1057,12 +1028,9 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) uint8 BankTabDst, BankTabSlotDst, unk2, ToChar = 1; uint32 ItemEntry, unk1; - CHECK_PACKET_SIZE(recv_data,8+1); recv_data >> GoGuid >> BankToBank; if (BankToBank) { - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1+4+1+1+4+1+1); recv_data >> BankTabDst; recv_data >> BankTabSlotDst; recv_data >> unk1; // always 0 @@ -1079,26 +1047,18 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) } else { - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1+4+1); recv_data >> BankTab; recv_data >> BankTabSlot; recv_data >> ItemEntry; recv_data >> AutoStore; if (AutoStore) { - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1); recv_data >> AutoStoreCount; } - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1); recv_data >> PlayerBag; recv_data >> PlayerSlot; if (!AutoStore) { - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+1+1); recv_data >> ToChar; recv_data >> SplitedAmount; } @@ -1554,7 +1514,6 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_BUY_TAB)"); - CHECK_PACKET_SIZE(recv_data, 8+1); //recv_data.hexlike(); uint64 GoGuid; uint8 TabId; @@ -1602,7 +1561,6 @@ void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)"); //recv_data.hexlike(); - CHECK_PACKET_SIZE(recv_data, 8+1+1+1); uint64 GoGuid; uint8 TabId; std::string Name; @@ -1638,7 +1596,6 @@ void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data ) void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data ) { sLog.outDebug("WORLD: Received (MSG_GUILD_BANK_LOG_QUERY)"); - CHECK_PACKET_SIZE(recv_data, 1); uint32 GuildId = GetPlayer()->GetGuildId(); if (GuildId == 0) @@ -1657,7 +1614,6 @@ void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data ) void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data) { sLog.outDebug("WORLD: Received MSG_QUERY_GUILD_BANK_TEXT"); - CHECK_PACKET_SIZE(recv_data, 1); uint32 GuildId = GetPlayer()->GetGuildId(); if (GuildId == 0) @@ -1676,8 +1632,6 @@ void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data) void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data) { sLog.outDebug("WORLD: Received CMSG_SET_GUILD_BANK_TEXT"); - CHECK_PACKET_SIZE(recv_data, 1+1); - uint32 GuildId = GetPlayer()->GetGuildId(); if (GuildId == 0) return; diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 1f079abff..3de5a326f 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -29,8 +29,6 @@ void WorldSession::HandleSplitItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1+1+1+1); - //sLog.outDebug("WORLD: CMSG_SPLIT_ITEM"); uint8 srcbag, srcslot, dstbag, dstslot, count; @@ -63,8 +61,6 @@ void WorldSession::HandleSplitItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleSwapInvItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1); - //sLog.outDebug("WORLD: CMSG_SWAP_INV_ITEM"); uint8 srcslot, dstslot; @@ -95,7 +91,6 @@ void WorldSession::HandleSwapInvItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleAutoEquipItemSlotOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+1); uint64 itemguid; uint8 dstslot; recv_data >> itemguid >> dstslot; @@ -115,8 +110,6 @@ void WorldSession::HandleAutoEquipItemSlotOpcode( WorldPacket & recv_data ) void WorldSession::HandleSwapItem( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1+1+1); - //sLog.outDebug("WORLD: CMSG_SWAP_ITEM"); uint8 dstbag, dstslot, srcbag, srcslot; @@ -147,8 +140,6 @@ void WorldSession::HandleSwapItem( WorldPacket & recv_data ) void WorldSession::HandleAutoEquipItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1); - //sLog.outDebug("WORLD: CMSG_AUTOEQUIP_ITEM"); uint8 srcbag, srcslot; @@ -250,8 +241,6 @@ void WorldSession::HandleAutoEquipItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleDestroyItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1+1+1+1+1); - //sLog.outDebug("WORLD: CMSG_DESTROYITEM"); uint8 bag, slot, count, data1, data2, data3; @@ -290,8 +279,6 @@ void WorldSession::HandleDestroyItemOpcode( WorldPacket & recv_data ) // Only _static_ data send in this packet !!! void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - //sLog.outDebug("WORLD: CMSG_ITEM_QUERY_SINGLE"); uint32 item; recv_data >> item; @@ -453,8 +440,6 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) void WorldSession::HandleReadItem( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1); - //sLog.outDebug( "WORLD: CMSG_READ_ITEM"); uint8 bag, slot; @@ -488,8 +473,6 @@ void WorldSession::HandleReadItem( WorldPacket & recv_data ) void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); - sLog.outDebug( "WORLD: Received CMSG_PAGE_TEXT_QUERY" ); uint32 itemid; @@ -503,8 +486,6 @@ void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket & recv_data ) void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+8+1); - sLog.outDebug( "WORLD: Received CMSG_SELL_ITEM" ); uint64 vendorguid, itemguid; uint8 _count; @@ -614,8 +595,6 @@ void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleBuybackItem(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,8+4); - sLog.outDebug( "WORLD: Received CMSG_BUYBACK_ITEM" ); uint64 vendorguid; uint32 slot; @@ -663,8 +642,6 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) void WorldSession::HandleBuyItemInSlotOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4+8+1+4); - sLog.outDebug( "WORLD: Received CMSG_BUY_ITEM_IN_SLOT" ); uint64 vendorguid, bagguid; uint32 item, slot, count; @@ -701,8 +678,6 @@ void WorldSession::HandleBuyItemInSlotOpcode( WorldPacket & recv_data ) void WorldSession::HandleBuyItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4+4+1); - sLog.outDebug( "WORLD: Received CMSG_BUY_ITEM" ); uint64 vendorguid; uint32 item, slot, count; @@ -715,8 +690,6 @@ void WorldSession::HandleBuyItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleListInventoryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -799,8 +772,6 @@ void WorldSession::SendListInventory( uint64 vendorguid ) void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1+1); - //sLog.outDebug("WORLD: CMSG_AUTOSTORE_BAG_ITEM"); uint8 srcbag, srcslot, dstbag; @@ -852,8 +823,6 @@ void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 8); - sLog.outDebug("WORLD: CMSG_BUY_BANK_SLOT"); uint64 guid; @@ -893,8 +862,6 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1+1); - sLog.outDebug("WORLD: CMSG_AUTOBANK_ITEM"); uint8 srcbag, srcslot; @@ -919,8 +886,6 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1+1); - sLog.outDebug("WORLD: CMSG_AUTOSTORE_BANK_ITEM"); uint8 srcbag, srcslot; @@ -961,8 +926,6 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleSetAmmoOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - if(!GetPlayer()->isAlive()) { GetPlayer()->SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, NULL, NULL ); @@ -1004,8 +967,6 @@ void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 itemid; recv_data >> itemid; sLog.outDebug("WORLD: CMSG_ITEM_NAME_QUERY %u", itemid); @@ -1045,8 +1006,6 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,1+1+1+1); - sLog.outDebug("Received opcode CMSG_WRAP_ITEM"); uint8 gift_bag, gift_slot, item_bag, item_slot; @@ -1154,8 +1113,6 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) { sLog.outDebug("WORLD: CMSG_SOCKET_GEMS"); - CHECK_PACKET_SIZE(recv_data,8+8*MAX_GEM_SOCKETS); - uint64 item_guid; uint64 gem_guids[MAX_GEM_SOCKETS]; @@ -1356,8 +1313,6 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) { sLog.outDebug("WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT"); - CHECK_PACKET_SIZE(recv_data,4); - uint32 eslot; recv_data >> eslot; diff --git a/src/game/LFGHandler.cpp b/src/game/LFGHandler.cpp index 5175fa4a3..a325afee5 100644 --- a/src/game/LFGHandler.cpp +++ b/src/game/LFGHandler.cpp @@ -205,8 +205,6 @@ void WorldSession::HandleLfmClearOpcode( WorldPacket & /*recv_data */) void WorldSession::HandleSetLfmOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4+1+1+1+1); - sLog.outDebug("CMSG_SET_LOOKING_FOR_MORE"); //recv_data.hexlike(); uint32 temp, entry, type; @@ -229,8 +227,6 @@ void WorldSession::HandleSetLfmOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetLfgCommentOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1); - sLog.outDebug("CMSG_SET_LFG_COMMENT"); //recv_data.hexlike(); @@ -243,8 +239,6 @@ void WorldSession::HandleSetLfgCommentOpcode( WorldPacket & recv_data ) void WorldSession::HandleLookingForGroup(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 4+4+4); - sLog.outDebug("MSG_LOOKING_FOR_GROUP"); //recv_data.hexlike(); uint32 type, entry, unk; @@ -397,8 +391,6 @@ void WorldSession::SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type) void WorldSession::HandleSetLfgOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4+4+1+1); - sLog.outDebug("CMSG_SET_LOOKING_FOR_GROUP"); recv_data.hexlike(); uint32 slot, temp, entry, type; @@ -425,8 +417,6 @@ void WorldSession::HandleSetLfgOpcode( WorldPacket & recv_data ) void WorldSession::HandleLfgSetRoles(WorldPacket &recv_data) { - CHECK_PACKET_SIZE(recv_data, 1); - sLog.outDebug("CMSG_LFG_SET_ROLES"); uint8 roles; diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 06c84aeff..da7c2bb6a 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -32,8 +32,6 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); - sLog.outDebug("WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); Player *player = GetPlayer(); uint64 lguid = player->GetLootGUID(); @@ -240,8 +238,6 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug("WORLD: CMSG_LOOT"); uint64 guid; @@ -256,8 +252,6 @@ void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug("WORLD: CMSG_LOOT_RELEASE"); // cheaters can modify lguid to prevent correct apply loot release code and re-loot @@ -437,8 +431,6 @@ void WorldSession::DoLootRelease( uint64 lguid ) void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+1+8); - uint8 slotid; uint64 lootguid, target_playerguid; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 139302047..74c2e32f0 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -52,8 +52,6 @@ void MailItem::deleteItem( bool inDB ) void WorldSession::HandleSendMail(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+1+1+1+4+4+1+4+4+8+1); - uint64 mailbox, unk3; std::string receiver, subject, body; uint32 unk1, unk2, money, COD; @@ -64,19 +62,10 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - // recheck - CHECK_PACKET_SIZE(recv_data, 8+(receiver.size()+1)+1+1+4+4+1+4+4+8+1); - recv_data >> subject; - // recheck - CHECK_PACKET_SIZE(recv_data, 8+(receiver.size()+1)+(subject.size()+1)+1+4+4+1+4+4+8+1); - recv_data >> body; - // recheck - CHECK_PACKET_SIZE(recv_data, 8+(receiver.size()+1)+(subject.size()+1)+(body.size()+1)+4+4+1+4+4+8+1); - recv_data >> unk1; // stationery? recv_data >> unk2; // 0x00000000 @@ -91,9 +80,6 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) return; } - // recheck - CHECK_PACKET_SIZE(recv_data, 8+(receiver.size()+1)+(subject.size()+1)+(body.size()+1)+4+4+1+items_count*(1+8)+4+4+8+1); - if(items_count) { for(uint8 i = 0; i < items_count; ++i) @@ -297,8 +283,6 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) //called when mail is read void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 mailbox; uint32 mailId; recv_data >> mailbox; @@ -323,8 +307,6 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) //called when client deletes mail void WorldSession::HandleMailDelete(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 mailbox; uint32 mailId; recv_data >> mailbox; @@ -343,8 +325,6 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 mailbox; uint32 mailId; recv_data >> mailbox; @@ -443,8 +423,6 @@ void WorldSession::SendReturnToSender(uint8 messageType, uint32 sender_acc, uint //called when player takes item attached in mail void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - uint64 mailbox; uint32 mailId; uint32 itemId; @@ -538,8 +516,6 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 mailbox; uint32 mailId; recv_data >> mailbox; @@ -574,8 +550,6 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) //called when player lists his received mails void WorldSession::HandleGetMailList(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 mailbox; recv_data >> mailbox; @@ -696,8 +670,6 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) ///this function is called when client needs mail message body, or when player clicks on item which has ITEM_FIELD_ITEM_TEXT_ID > 0 void WorldSession::HandleItemTextQuery(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+4+4); - uint32 itemTextId; uint32 mailId; //this value can be item id in bag, but it is also mail id uint32 unk; //maybe something like state - 0x70000000 @@ -717,8 +689,6 @@ void WorldSession::HandleItemTextQuery(WorldPacket & recv_data ) //used when player copies mail body to his inventory void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 mailbox; uint32 mailId; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index d9cff6874..4531f5146 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -66,8 +66,6 @@ void WorldSession::HandleRepopRequestOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+4+1+1+4+4+4+4); - sLog.outDebug( "WORLD: Recvd CMSG_WHO Message" ); //recv_data.hexlike(); @@ -81,14 +79,8 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) recv_data >> level_max; // minimal player level, default 100 (MAX_LEVEL) recv_data >> player_name; // player name, case sensitive... - // recheck - CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+1+4+4+4+4); - recv_data >> guild_name; // guild name, case sensitive... - // recheck - CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+(guild_name.size()+1)+4+4+4+4); - recv_data >> racemask; // race mask recv_data >> classmask; // class mask recv_data >> zones_count; // zones count, client limit=10 (2.0.10) @@ -96,9 +88,6 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if(zones_count > 10) return; // can't be received from real client or broken packet - // recheck - CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+(guild_name.size()+1)+4+4+4+(4*zones_count)+4); - for(uint32 i = 0; i < zones_count; ++i) { uint32 temp; @@ -112,17 +101,11 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if(str_count > 4) return; // can't be received from real client or broken packet - // recheck - CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+(guild_name.size()+1)+4+4+4+(4*zones_count)+4+(1*str_count)); - sLog.outDebug("Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count); std::wstring str[4]; // 4 is client limit for(uint32 i = 0; i < str_count; ++i) { - // recheck (have one more byte) - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()); - std::string temp; recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)? @@ -381,8 +364,6 @@ void WorldSession::HandleTogglePvP( WorldPacket & recv_data ) void WorldSession::HandleZoneUpdateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 newZone; recv_data >> newZone; @@ -397,8 +378,6 @@ void WorldSession::HandleZoneUpdateOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data ) { // When this packet send? - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid ; recv_data >> guid; @@ -415,8 +394,6 @@ void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -433,8 +410,6 @@ void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); - sLog.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" ); uint8 animstate; recv_data >> animstate; @@ -444,7 +419,6 @@ void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) void WorldSession::HandleContactListOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); sLog.outDebug( "WORLD: Received CMSG_CONTACT_LIST" ); uint32 unk; recv_data >> unk; @@ -454,8 +428,6 @@ void WorldSession::HandleContactListOpcode( WorldPacket & recv_data ) void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1+1); - sLog.outDebug( "WORLD: Received CMSG_ADD_FRIEND" ); std::string friendName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN); @@ -463,9 +435,6 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) recv_data >> friendName; - // recheck - CHECK_PACKET_SIZE(recv_data, (friendName.size()+1)+1); - recv_data >> friendNote; if(!normalizePlayerName(friendName)) @@ -527,8 +496,6 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 FriendGUID; sLog.outDebug( "WORLD: Received CMSG_DEL_FRIEND" ); @@ -544,8 +511,6 @@ void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,1); - sLog.outDebug( "WORLD: Received CMSG_ADD_IGNORE" ); std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN); @@ -600,8 +565,6 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 IgnoreGUID; sLog.outDebug( "WORLD: Received CMSG_DEL_IGNORE" ); @@ -617,7 +580,6 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+1); sLog.outDebug("CMSG_SET_CONTACT_NOTES"); uint64 guid; std::string note; @@ -627,8 +589,6 @@ void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+4+1+4+1); - uint32 suggestion, contentlen; std::string content; uint32 typelen; @@ -636,9 +596,6 @@ void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) recv_data >> suggestion >> contentlen >> content; - //recheck - CHECK_PACKET_SIZE(recv_data,4+4+(content.size()+1)+4+1); - recv_data >> typelen >> type; if( suggestion == 0 ) @@ -646,8 +603,8 @@ void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) else sLog.outDebug( "WORLD: Received CMSG_BUG [Suggestion]" ); - sLog.outDebug( type.c_str( ) ); - sLog.outDebug( content.c_str( ) ); + sLog.outDebug("%s", type.c_str() ); + sLog.outDebug("%s", content.c_str() ); CharacterDatabase.escape_string(type); CharacterDatabase.escape_string(content); @@ -656,8 +613,6 @@ void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDetail("WORLD: Received CMSG_RECLAIM_CORPSE"); if (GetPlayer()->isAlive()) return; @@ -696,8 +651,6 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,8+1); - sLog.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE"); if(GetPlayer()->isAlive()) @@ -723,8 +676,6 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - sLog.outDebug("WORLD: Received CMSG_AREATRIGGER"); uint32 Trigger_ID; @@ -895,8 +846,6 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) { sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); - CHECK_PACKET_SIZE(recv_data, 4+4+4); - uint32 type, timestamp, decompressedSize; recv_data >> type >> timestamp >> decompressedSize; @@ -948,8 +897,6 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) { sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA"); - CHECK_PACKET_SIZE(recv_data, 4); - uint32 type; recv_data >> type; @@ -986,8 +933,6 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,1+2+1+1); - sLog.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" ); uint8 button; uint32 packetData; @@ -1043,7 +988,6 @@ void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & /*recv_data*/ ) DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" ); /* - CHECK_PACKET_SIZE(recv_data,8+4); uint64 guid; uint32 time_skipped; recv_data >> guid; @@ -1066,7 +1010,6 @@ void WorldSession::HandleFeatherFallAck(WorldPacket &/*recv_data*/) void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) { /* - CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4); sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); recv_data.hexlike(); @@ -1100,8 +1043,6 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) { /* - CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4); - sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" ); recv_data.hexlike(); uint64 guid; @@ -1133,8 +1074,6 @@ void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,1); - uint8 ActionBar; recv_data >> ActionBar; @@ -1152,8 +1091,6 @@ void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data) void WorldSession::HandleWardenDataOpcode(WorldPacket& /*recv_data*/) { /* - CHECK_PACKET_SIZE(recv_data,1); - uint8 tmp; recv_data >> tmp; sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u",tmp); @@ -1162,8 +1099,6 @@ void WorldSession::HandleWardenDataOpcode(WorldPacket& /*recv_data*/) void WorldSession::HandlePlayedTime(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 1); - uint8 unk1; recv_data >> unk1; // 0 or 1 expected @@ -1176,8 +1111,6 @@ void WorldSession::HandlePlayedTime(WorldPacket& recv_data) void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; DEBUG_LOG("Inspected guid is (GUID: %u TypeId: %u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid))); @@ -1209,8 +1142,6 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; @@ -1234,8 +1165,6 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,4+4+4+4+4+4); - // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180 // Received opcode CMSG_WORLD_TELEPORT // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593 @@ -1272,8 +1201,6 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 1); - sLog.outDebug("Received opcode CMSG_WHOIS"); std::string charname; recv_data >> charname; @@ -1331,7 +1258,6 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1+8); sLog.outDebug("WORLD: CMSG_COMPLAIN"); recv_data.hexlike(); @@ -1347,13 +1273,11 @@ void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) switch(spam_type) { case 0: - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4); recv_data >> unk1; // const 0 recv_data >> unk2; // probably mail id recv_data >> unk3; // const 0 break; case 1: - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4+1); recv_data >> unk1; // probably language recv_data >> unk2; // message type? recv_data >> unk3; // probably channel id @@ -1375,8 +1299,6 @@ void WorldSession::HandleComplainOpcode( WorldPacket & recv_data ) void WorldSession::HandleRealmSplitOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - sLog.outDebug("CMSG_REALM_SPLIT"); uint32 unk; @@ -1397,8 +1319,6 @@ void WorldSession::HandleRealmSplitOpcode( WorldPacket & recv_data ) void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1); - sLog.outDebug("WORLD: CMSG_FAR_SIGHT"); //recv_data.hexlike(); @@ -1421,8 +1341,6 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - sLog.outDebug("CMSG_SET_TITLE"); int32 title; @@ -1442,8 +1360,6 @@ void WorldSession::HandleSetTitleOpcode( WorldPacket & recv_data ) void WorldSession::HandleTimeSyncResp( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4+4); - sLog.outDebug("CMSG_TIME_SYNC_RESP"); uint32 counter, time_; @@ -1470,8 +1386,6 @@ void WorldSession::HandleResetInstancesOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - sLog.outDebug("MSG_SET_DUNGEON_DIFFICULTY"); uint32 mode; @@ -1538,8 +1452,6 @@ void WorldSession::HandleCancelMountAuraOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4+4); - // fly mode on/off sLog.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); //recv_data.hexlike(); @@ -1563,8 +1475,6 @@ void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1); - uint8 mode; recv_data >> mode; @@ -1573,7 +1483,6 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) void WorldSession::HandleQueryInspectAchievements( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 1); uint64 guid; if(!recv_data.readPackGUID(guid)) return; diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index b35bc653d..ebc38163b 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -160,8 +160,6 @@ void WorldSession::HandleMoveWorldportAckOpcode() void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+4+4); - sLog.outDebug("MSG_MOVE_TELEPORT_ACK"); uint64 guid; uint32 flags, time; @@ -343,8 +341,6 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) { sLog.outDebug("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(recv_data.GetOpcode()), recv_data.GetOpcode(), recv_data.GetOpcode()); - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4); - /* extract packet */ uint64 guid; uint32 unk1; @@ -363,9 +359,6 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) MovementInfo movementInfo; ReadMovementInfo(recv_data, &movementInfo); - // recheck - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); - recv_data >> newspeed; /*----------------*/ @@ -424,8 +417,6 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) sLog.outDebug("WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); recv_data.hexlike(); - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; @@ -441,8 +432,6 @@ void WorldSession::HandleMoveNotActiveMover(WorldPacket &recv_data) sLog.outDebug("WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); recv_data.hexlike(); - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8); - uint64 old_mover_guid; recv_data >> old_mover_guid; @@ -491,7 +480,6 @@ void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/) void WorldSession::HandleMoveKnockBackAck( WorldPacket & /*recv_data*/ ) { - // CHECK_PACKET_SIZE(recv_data,?); sLog.outDebug("CMSG_MOVE_KNOCK_BACK_ACK"); // Currently not used but maybe use later for recheck final player position // (must be at call same as into "recv_data >> x >> y >> z >> orientation;" @@ -531,8 +519,6 @@ void WorldSession::HandleMoveWaterWalkAck(WorldPacket& /*recv_data*/) void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+1); - if(!_player->isAlive() || _player->isInCombat() ) return; diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index e5fb150bd..fd15a1d4e 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -38,8 +38,6 @@ void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -66,8 +64,6 @@ void WorldSession::SendTabardVendorActivate( uint64 guid ) void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; sLog.outDebug( "WORLD: Received CMSG_BANKER_ACTIVATE" ); @@ -97,8 +93,6 @@ void WorldSession::SendShowBank( uint64 guid ) void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -194,8 +188,6 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint64 guid; uint32 spellId = 0; @@ -261,8 +253,6 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug( "WORLD: Received CMSG_GOSSIP_HELLO" ); uint64 guid; @@ -306,8 +296,6 @@ void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION"); uint32 option; @@ -319,8 +307,6 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) if(_player->PlayerTalkClass->GossipOptionCoded( option )) { - // recheck - CHECK_PACKET_SIZE(recv_data,8+4+1); sLog.outBasic("reading string"); recv_data >> code; sLog.outBasic("string read: %s", code.c_str()); @@ -351,8 +337,6 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); uint64 guid; @@ -410,8 +394,6 @@ void WorldSession::SendSpiritResurrect() void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 npcGUID; recv_data >> npcGUID; @@ -483,8 +465,6 @@ void WorldSession::SendBindPoint(Creature *npc) void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS"); uint64 npcGUID; @@ -559,8 +539,6 @@ void WorldSession::SendStablePet(uint64 guid ) void WorldSession::HandleStablePet( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("WORLD: Recv CMSG_STABLE_PET"); uint64 npcGUID; @@ -628,8 +606,6 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4); - sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET."); uint64 npcGUID; uint32 petnumber; @@ -708,8 +684,6 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT."); uint64 npcGUID; @@ -753,8 +727,6 @@ void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4); - sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET."); uint64 npcGUID; uint32 pet_number; @@ -826,8 +798,6 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+8+1); - sLog.outDebug("WORLD: CMSG_REPAIR_ITEM"); uint64 npcGUID, itemGUID; diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index b665a0584..c40cea1d8 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -31,8 +31,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+2+2+8); - uint64 guid1; uint32 data; uint64 guid2; @@ -265,8 +263,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) void WorldSession::HandlePetNameQuery( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); - sLog.outDetail( "HandlePetNameQuery. CMSG_PET_NAME_QUERY" ); uint32 petnumber; @@ -305,8 +301,6 @@ void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber) void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4+2+2); - sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION" ); uint64 petguid; @@ -379,8 +373,6 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) void WorldSession::HandlePetRename( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+1); - sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME" ); uint64 petguid; @@ -391,7 +383,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) recv_data >> petguid; recv_data >> name; - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> isdeclined; Pet* pet = ObjectAccessor::GetPet(petguid); @@ -426,7 +417,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) { for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { - CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> declinedname.name[i]; } @@ -458,8 +448,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; //pet guid sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) ); @@ -490,8 +478,6 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8); - sLog.outDetail("CMSG_PET_UNLEARN"); uint64 guid; recvPacket >> guid; // Pet guid @@ -519,8 +505,6 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) { - CHECK_PACKET_SIZE(recvPacket,8+2+2+1); - sLog.outDetail("CMSG_PET_SPELL_AUTOCAST"); uint64 guid; uint32 spellid; @@ -565,7 +549,6 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) { sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL"); - CHECK_PACKET_SIZE(recvPacket,8+1+4+1); uint64 guid; uint32 spellid; uint8 cast_count; @@ -660,8 +643,6 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT"); - CHECK_PACKET_SIZE(recv_data, 8+4+4); - uint64 guid; uint32 talent_id, requested_rank; recv_data >> guid >> talent_id >> requested_rank; @@ -674,8 +655,6 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data ) { sLog.outDebug("CMSG_LEARN_PREVIEW_TALENTS_PET"); - CHECK_PACKET_SIZE(recv_data, 8+4); - uint64 guid; recv_data >> guid; @@ -686,8 +665,6 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data ) for(uint32 i = 0; i < talentsCount; ++i) { - CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4); - recv_data >> talentId >> talentRank; _player->LearnPetTalent(guid, talentId, talentRank); diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index e5da6cf84..ba4333f30 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -47,8 +47,6 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+8+4+1+5*8+2+1+4+4); - sLog.outDebug("Received opcode CMSG_PETITION_BUY"); //recv_data.hexlike(); @@ -65,9 +63,6 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) recv_data >> unk2; // 0 recv_data >> name; // name - // recheck - CHECK_PACKET_SIZE(recv_data, 8+8+4+(name.size()+1)+5*8+2+1+4+4); - recv_data >> unk3; // 0 recv_data >> unk4; // 0 recv_data >> unk5; // 0 @@ -236,8 +231,6 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - // ok sLog.outDebug("Received opcode CMSG_PETITION_SHOW_SIGNATURES"); //recv_data.hexlike(); @@ -293,8 +286,6 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 4+8); - sLog.outDebug("Received opcode CMSG_PETITION_QUERY"); // ok //recv_data.hexlike(); @@ -370,8 +361,6 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid) void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+1); - sLog.outDebug("Received opcode MSG_PETITION_RENAME"); // ok //recv_data.hexlike(); @@ -441,8 +430,6 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8+1); - sLog.outDebug("Received opcode CMSG_PETITION_SIGN"); // ok //recv_data.hexlike(); @@ -571,8 +558,6 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("Received opcode MSG_PETITION_DECLINE"); // ok //recv_data.hexlike(); @@ -600,8 +585,6 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 4+8+8); - sLog.outDebug("Received opcode CMSG_OFFER_PETITION"); // ok //recv_data.hexlike(); @@ -705,8 +688,6 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("Received opcode CMSG_TURN_IN_PETITION"); // ok //recv_data.hexlike(); @@ -853,7 +834,6 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) return; } - CHECK_PACKET_SIZE(recv_data, 8+5*4); uint32 icon, iconcolor, border, bordercolor, backgroud; recv_data >> backgroud >> icon >> iconcolor >> border >> bordercolor; @@ -891,8 +871,6 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data, 8); - sLog.outDebug("Received CMSG_PETITION_SHOWLIST"); // ok //recv_data.hexlike(); diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 69be7e1dc..87db09de6 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -127,8 +127,6 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; @@ -152,8 +150,6 @@ void WorldSession::HandleQueryTimeOpcode( WorldPacket & /*recv_data*/ ) /// Only _static_ data send in this packet !!! void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); - uint32 entry; recv_data >> entry; @@ -221,8 +217,6 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) /// Only _static_ data send in this packet !!! void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); - uint32 entryID; recv_data >> entryID; @@ -333,8 +327,6 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4 + 8); - uint32 textID; uint64 guid; @@ -421,8 +413,6 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - uint32 pageID; recv_data >> pageID; diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 5d2300676..c886a2a0d 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -32,8 +32,6 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; uint8 questStatus = DIALOG_STATUS_NONE; @@ -80,8 +78,6 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - uint64 guid; recv_data >> guid; @@ -110,8 +106,6 @@ void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4+4); - uint64 guid; uint32 quest; uint32 unk1; @@ -207,8 +201,6 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8+4+1); - uint64 guid; uint32 quest; uint8 unk1; @@ -232,8 +224,6 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 4); - uint32 quest; recv_data >> quest; sLog.outDebug( "WORLD: Received CMSG_QUEST_QUERY quest = %u",quest ); @@ -247,8 +237,6 @@ void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - uint32 quest, reward; uint64 guid; recv_data >> guid >> quest >> reward; @@ -305,8 +293,6 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint32 quest; uint64 guid; recv_data >> guid >> quest; @@ -339,8 +325,6 @@ void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/ ) void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data ) { - CHECK_PACKET_SIZE(recv_data,1+1); - uint8 slot1, slot2; recv_data >> slot1 >> slot2; @@ -354,8 +338,6 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data ) void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,1); - uint8 slot; recv_data >> slot; @@ -379,8 +361,6 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 quest; recv_data >> quest; @@ -389,8 +369,6 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) { - CHECK_PACKET_SIZE(recv_data,8+4); - uint32 quest; uint64 guid; recv_data >> guid >> quest; @@ -427,8 +405,6 @@ void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/) void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,4); - uint32 questId; recvPacket >> questId; @@ -486,8 +462,6 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8+1); - uint64 guid; uint8 msg; recvPacket >> guid >> msg; diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 81c0a1217..970406f79 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -28,8 +28,6 @@ void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+4); - uint32 talent_id, requested_rank; recv_data >> talent_id >> requested_rank; @@ -41,8 +39,6 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) { sLog.outDebug("CMSG_LEARN_PREVIEW_TALENTS"); - CHECK_PACKET_SIZE(recvPacket, 4); - uint32 talentsCount; recvPacket >> talentsCount; @@ -50,8 +46,6 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) for(uint32 i = 0; i < talentsCount; ++i) { - CHECK_PACKET_SIZE(recvPacket, recvPacket.rpos()+4+4); - recvPacket >> talentId >> talentRank; _player->LearnTalent(talentId, talentRank); @@ -62,8 +56,6 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDetail("MSG_TALENT_WIPE_CONFIRM"); uint64 guid; recv_data >> guid; @@ -94,8 +86,6 @@ void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data ) void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data) { - CHECK_PACKET_SIZE(recv_data,4); - uint32 skill_id; recv_data >> skill_id; GetPlayer()->SetSkill(skill_id, 0, 0); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 0f1c1c3ce..f616c8266 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -32,8 +32,6 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) { // TODO: add targets.read() check - CHECK_PACKET_SIZE(recvPacket,1+1+1+4+8+4+1); - Player* pUser = _player; // ignore for remote control state @@ -160,8 +158,6 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1+1); - sLog.outDetail("WORLD: CMSG_OPEN_ITEM packet, data length = %i",(uint32)recvPacket.size()); Player* pUser = _player; @@ -240,8 +236,6 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; @@ -265,8 +259,6 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8); - uint64 guid; recvPacket >> guid; @@ -288,8 +280,6 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1+4+1); - uint32 spellId; uint8 cast_count, unk_flags; recvPacket >> cast_count; @@ -353,8 +343,6 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,5); - // ignore for remote control state (for player case) Unit* mover = _player->m_mover; if(mover != _player && mover->GetTypeId()==TYPEID_PLAYER) @@ -376,8 +364,6 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,4); - uint32 spellId; recvPacket >> spellId; @@ -428,8 +414,6 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 8+4); - // ignore for remote control state if(_player->m_mover != _player) return; @@ -488,8 +472,6 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket* void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */) { /* - CHECK_PACKET_SIZE(recv_data, 4); - uint32 spellid; recv_data >> spellid; */ @@ -497,8 +479,6 @@ void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */) void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket, 1); - // ignore for remote control state if(_player->m_mover != _player) return; @@ -534,8 +514,6 @@ void WorldSession::HandleSelfResOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSpellClick( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data, 8); - uint64 guid; recv_data >> guid; diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index fe2f28c3b..271b978b1 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -29,12 +29,8 @@ #include "WaypointMovementGenerator.h" #include "DestinationHolderImp.h" -#include - void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug( "WORLD: Received CMSG_TAXINODE_STATUS_QUERY" ); uint64 guid; @@ -70,8 +66,6 @@ void WorldSession::SendTaxiStatus( uint64 guid ) void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); - sLog.outDebug( "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES" ); uint64 guid; @@ -158,8 +152,6 @@ bool WorldSession::SendLearnNewTaxiNode( Creature* unit ) void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS" ); uint64 guid; @@ -173,9 +165,6 @@ void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) sLog.outDebug( "WORLD: HandleActivateTaxiExpressOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); return; } - // recheck - CHECK_PACKET_SIZE(recv_data,8+4+4+node_count*4); - std::vector nodes; for(uint32 i = 0; i < node_count; ++i) @@ -258,8 +247,6 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/) void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+4+4); - sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXI" ); uint64 guid; diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp index 64408c6b5..b86ab2e6f 100644 --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -457,8 +457,6 @@ void WorldSession::HandleCancelTradeOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,8); - if (GetPlayer()->pTrader) return; @@ -558,8 +556,6 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) void WorldSession::HandleSetTradeGoldOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,4); - if(!_player->pTrader) return; @@ -575,8 +571,6 @@ void WorldSession::HandleSetTradeGoldOpcode(WorldPacket& recvPacket) void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1+1+1); - if(!_player->pTrader) return; @@ -624,8 +618,6 @@ void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleClearTradeItemOpcode(WorldPacket& recvPacket) { - CHECK_PACKET_SIZE(recvPacket,1); - if(!_player->pTrader) return; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 5c8b44bc8..85ba69609 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -173,43 +173,56 @@ bool WorldSession::Update(uint32 /*diff*/) else { OpcodeHandler& opHandle = opcodeTable[packet->GetOpcode()]; - switch (opHandle.status) + try { - case STATUS_LOGGEDIN: - if(!_player) - { - // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets - if(!m_playerRecentlyLogout) - logUnexpectedOpcode(packet, "the player has not logged in yet"); - } - else if(_player->IsInWorld()) - (this->*opHandle.handler)(*packet); - // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer - break; - case STATUS_TRANSFER: - if(!_player) - logUnexpectedOpcode(packet, "the player has not logged in yet"); - else if(_player->IsInWorld()) - logUnexpectedOpcode(packet, "the player is still in world"); - else - (this->*opHandle.handler)(*packet); - break; - case STATUS_AUTHED: - // prevent cheating with skip queue wait - if(m_inQueue) - { - logUnexpectedOpcode(packet, "the player not pass queue yet"); + switch (opHandle.status) + { + case STATUS_LOGGEDIN: + if(!_player) + { + // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets + if(!m_playerRecentlyLogout) + logUnexpectedOpcode(packet, "the player has not logged in yet"); + } + else if(_player->IsInWorld()) + (this->*opHandle.handler)(*packet); + // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; - } + case STATUS_TRANSFER: + if(!_player) + logUnexpectedOpcode(packet, "the player has not logged in yet"); + else if(_player->IsInWorld()) + logUnexpectedOpcode(packet, "the player is still in world"); + else + (this->*opHandle.handler)(*packet); + break; + case STATUS_AUTHED: + // prevent cheating with skip queue wait + if(m_inQueue) + { + logUnexpectedOpcode(packet, "the player not pass queue yet"); + break; + } - m_playerRecentlyLogout = false; - (this->*opHandle.handler)(*packet); - break; - case STATUS_NEVER: - sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); - break; + m_playerRecentlyLogout = false; + (this->*opHandle.handler)(*packet); + break; + case STATUS_NEVER: + sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)", + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode()); + break; + } + } + catch(ByteBufferException &exception) + { + sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.", + packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId()); + if(sLog.IsOutDebug()) + { + sLog.outDebug("Dumping error causing packet:"); + packet->hexlike(); + } } } @@ -629,7 +642,6 @@ void WorldSession::SaveTutorialsData() void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi) { - CHECK_PACKET_SIZE(data, data.rpos()+4+2+4+4+4+4+4); data >> mi->flags; data >> mi->unk1; data >> mi->time; @@ -643,7 +655,6 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi) if(!data.readPackGUID(mi->t_guid)) return; - CHECK_PACKET_SIZE(data, data.rpos()+4+4+4+4+4+1); data >> mi->t_x; data >> mi->t_y; data >> mi->t_z; @@ -654,16 +665,13 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi) if((mi->HasMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2))) || (mi->unk1 & 0x20)) { - CHECK_PACKET_SIZE(data, data.rpos()+4); data >> mi->s_pitch; } - CHECK_PACKET_SIZE(data, data.rpos()+4); data >> mi->fallTime; if(mi->HasMovementFlag(MOVEMENTFLAG_JUMPING)) { - CHECK_PACKET_SIZE(data, data.rpos()+4+4+4+4); data >> mi->j_unk; data >> mi->j_sinAngle; data >> mi->j_cosAngle; @@ -672,7 +680,6 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi) if(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE)) { - CHECK_PACKET_SIZE(data, data.rpos()+4); data >> mi->u_unk1; } } @@ -687,6 +694,12 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data) if(!size) return; + if(size > 0xFFFFF) + { + sLog.outError("WorldSession::ReadAddonsInfo addon info too big, size %u", size); + return; + } + uLongf uSize = size; uint32 pos = data.rpos(); @@ -711,10 +724,6 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data) addonInfo >> addonName; - // recheck next addon data format correctness - if(addonInfo.rpos()+1+4+4 > addonInfo.size()) - return; - addonInfo >> enabled >> crc >> unk1; sLog.outDebug("ADDON: Name: %s, Enabled: 0x%x, CRC: 0x%x, Unknown2: 0x%x", addonName.c_str(), enabled, crc, unk1); diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 38fe40af0..4b963b75a 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -44,8 +44,6 @@ class QueryResult; class LoginQueryHolder; class CharacterHandler; -#define CHECK_PACKET_SIZE(P,S) if((P).size() < (S)) return SizeError((P),(S)); - #define NUM_ACCOUNT_DATA_TYPES 8 struct AccountData diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 95e93c417..b2af3aa0d 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -694,45 +694,55 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) sWorldLog.Log ("\n\n"); } - // like one switch ;) - if (opcode == CMSG_PING) - { - return HandlePing (*new_pct); - } - else if (opcode == CMSG_AUTH_SESSION) - { - if (m_Session) + try { + switch(opcode) { - sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); - return -1; + case CMSG_PING: + return HandlePing (*new_pct); + case CMSG_AUTH_SESSION: + if (m_Session) + { + sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); + return -1; + } + + return HandleAuthSession (*new_pct); + case CMSG_KEEP_ALIVE: + DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size ()); + + return 0; + default: + { + ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + + if (m_Session != NULL) + { + // OK ,give the packet to WorldSession + aptr.release (); + // WARNINIG here we call it with locks held. + // Its possible to cause deadlock if QueuePacket calls back + m_Session->QueuePacket (new_pct); + return 0; + } + else + { + sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); + return -1; + } + } + } + } + catch(ByteBufferException &exception) + { + sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.", + opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1); + if(sLog.IsOutDebug()) + { + sLog.outDebug("Dumping error causing packet:"); + new_pct->hexlike(); } - return HandleAuthSession (*new_pct); - } - else if (opcode == CMSG_KEEP_ALIVE) - { - DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size ()); - - return 0; - } - else - { - ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); - - if (m_Session != NULL) - { - // OK ,give the packet to WorldSession - aptr.release (); - // WARNINIG here we call it with locks held. - // Its possible to cause deadlock if QueuePacket calls back - m_Session->QueuePacket (new_pct); - return 0; - } - else - { - sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); - return -1; - } + return -1; } ACE_NOTREACHED (return 0); @@ -755,24 +765,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) BigNumber K; - if (recvPacket.size () < (4 + 4 + 1 + 4 + 4 + 20)) - { - sLog.outError ("WorldSocket::HandleAuthSession: wrong packet size"); - return -1; - } - // Read the content of the packet recvPacket >> BuiltNumberClient; // for now no use recvPacket >> unk2; recvPacket >> account; recvPacket >> unk3; - - if (recvPacket.size () < (4 + 4 + (account.size () + 1) + 4 + 4 + 20)) - { - sLog.outError ("WorldSocket::HandleAuthSession: wrong packet size second check"); - return -1; - } - recvPacket >> clientSeed; recvPacket.read (digest, 20); @@ -1001,12 +998,6 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket) uint32 ping; uint32 latency; - if (recvPacket.size () < 8) - { - sLog.outError ("WorldSocket::_HandlePing wrong packet size"); - return -1; - } - // Get the ping packet content recvPacket >> ping; recvPacket >> latency; diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index 02e6aad80..4c1bc8a99 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -766,6 +766,7 @@ bool AuthSocket::_HandleReconnectChallenge() _login = (const char*)ch->I; _safelogin = _login; + loginDatabase.escape_string(_safelogin); QueryResult *result = loginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ()); diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 3d59a8469..795c76972 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -24,6 +24,26 @@ #include "Log.h" #include "Utilities/ByteConverter.h" +class ByteBufferException +{ + public: + ByteBufferException(bool add, size_t pos, size_t esize, size_t size):add(add), pos(pos), esize(esize), size(size) + { + PrintPosError(); + } + + void PrintPosError() const + { + sLog.outError("ERROR: Attempted to %s in ByteBuffer (pos: %lu size: %lu) value with size: %lu",(add ? "put" : "get"),(unsigned long)pos, (unsigned long)size, (unsigned long)esize); + + } + private: + bool add; + size_t pos; + size_t esize; + size_t size; +}; + class ByteBuffer { public: @@ -248,7 +268,8 @@ class ByteBuffer template T read(size_t pos) const { - ASSERT(pos + sizeof(T) <= size() || PrintPosError(false, pos, sizeof(T))); + if(pos + sizeof(T) > size()) + throw ByteBufferException(false, pos, sizeof(T), size()); T val = *((T const*)&_storage[pos]); EndianConvert(val); return val; @@ -256,7 +277,8 @@ class ByteBuffer void read(uint8 *dest, size_t len) { - ASSERT(_rpos + len <= size() || PrintPosError(false, _rpos, len)); + if(_rpos + len > size()) + throw ByteBufferException(false, _rpos, len, size()); memcpy(dest, &_storage[_rpos], len); _rpos += len; } @@ -370,7 +392,8 @@ class ByteBuffer void put(size_t pos, const uint8 *src, size_t cnt) { - ASSERT(pos + cnt <= size() || PrintPosError(true, pos, cnt)); + if(pos + cnt > size()) + throw ByteBufferException(true, pos, cnt, size()); memcpy(&_storage[pos], src, cnt); } @@ -459,14 +482,6 @@ class ByteBuffer } protected: - bool PrintPosError(bool add, size_t pos, size_t esize) const - { - sLog.outError("ERROR: Attempt %s in ByteBuffer (pos: %lu size: %lu) value with size: %lu",(add ? "put" : "get"),(unsigned long)pos, (unsigned long)size(), (unsigned long)esize); - - // assert must fail after function call - return false; - } - size_t _rpos, _wpos; std::vector _storage; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 51e874749..71ec55edf 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8377" + #define REVISION_NR "8378" #endif // __REVISION_NR_H__