From 65f505ea28f29738e4d874f55d96d6e2579ba757 Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Thu, 3 Apr 2025 22:44:17 +0000 Subject: Fix wrong read of clif_GM_kickack packet 2024-08/01/#Debug.log:[14:25:43] Wrong actual or planned inbound packet size!. Packet id: 205(0xcd), Planned size: 3, Actual size: 6 2 bytes packet id + 1 byte flag = 3 2 bytes packet id + 4 byte flag (wrong) = 6 Squashed with: * Separate processKickAck handler for eathena * Move ea's adminrecv and its sole handler processKickAck into TMWA namespace * Revert "Fix wrong read of clif_GM_kickack packet" This would break TMWA packet processing, as @thorbjorn pointed out. This reverts commit efe43bac4de90b3e427d985b77cb3dd3206bcf9d. **** mana/plus!148 --- src/CMakeLists.txt | 4 ++-- src/Makefile.am | 4 ++-- src/net/ea/adminrecv.cpp | 45 ------------------------------------------- src/net/ea/adminrecv.h | 42 ---------------------------------------- src/net/eathena/adminrecv.cpp | 12 ++++++++++++ src/net/eathena/adminrecv.h | 1 + src/net/eathena/network.cpp | 1 - src/net/eathena/packetsin.inc | 2 +- src/net/tmwa/adminrecv.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ src/net/tmwa/adminrecv.h | 42 ++++++++++++++++++++++++++++++++++++++++ src/net/tmwa/network.cpp | 2 +- src/net/tmwa/packetsin.inc | 2 +- 12 files changed, 107 insertions(+), 95 deletions(-) delete mode 100644 src/net/ea/adminrecv.cpp delete mode 100644 src/net/ea/adminrecv.h create mode 100644 src/net/tmwa/adminrecv.cpp create mode 100644 src/net/tmwa/adminrecv.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f5a22e0f..6195f9260 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2010,8 +2010,6 @@ SET(DYE_CMD_SRCS ) SET(SRCS_EVOL - net/ea/adminrecv.cpp - net/ea/adminrecv.h net/ea/adminhandler.cpp net/ea/adminhandler.h net/ea/beingrecv.cpp @@ -2082,6 +2080,8 @@ SET(SRCS_TMWA gui/windows/shopselldialog.h net/tmwa/adminhandler.cpp net/tmwa/adminhandler.h + net/tmwa/adminrecv.cpp + net/tmwa/adminrecv.h net/tmwa/achievementhandler.cpp net/tmwa/achievementhandler.h net/tmwa/attendancehandler.cpp diff --git a/src/Makefile.am b/src/Makefile.am index f11d310e4..394a7bd45 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1639,8 +1639,6 @@ SRC = ${BASE_SRC} \ net/protocoloutdefine.h \ net/protocoloutinclude.h \ net/protocoloutupdate.h \ - net/ea/adminrecv.cpp \ - net/ea/adminrecv.h \ net/ea/adminhandler.cpp \ net/ea/adminhandler.h \ net/ea/beingrecv.cpp \ @@ -1728,6 +1726,8 @@ SRC += \ gui/windows/shopselldialog.h \ net/tmwa/adminhandler.cpp \ net/tmwa/adminhandler.h \ + net/tmwa/adminrecv.cpp \ + net/tmwa/adminrecv.h \ net/tmwa/achievementhandler.cpp \ net/tmwa/achievementhandler.h \ net/tmwa/attendancehandler.cpp \ diff --git a/src/net/ea/adminrecv.cpp b/src/net/ea/adminrecv.cpp deleted file mode 100644 index efc55762f..000000000 --- a/src/net/ea/adminrecv.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2020 The ManaPlus Developers - * Copyright (C) 2020-2023 The ManaVerse Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "net/ea/adminrecv.h" - -#include "notifymanager.h" - -#include "enums/resources/notifytypes.h" - -#include "net/messagein.h" - -#include "debug.h" - -namespace Ea -{ - -void AdminRecv::processKickAck(Net::MessageIn &msg) -{ - if (msg.readInt32("flag") == 0) - NotifyManager::notify(NotifyTypes::KICK_FAIL); - else - NotifyManager::notify(NotifyTypes::KICK_SUCCEED); -} - -} // namespace Ea diff --git a/src/net/ea/adminrecv.h b/src/net/ea/adminrecv.h deleted file mode 100644 index 41f8121d3..000000000 --- a/src/net/ea/adminrecv.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2020 The ManaPlus Developers - * Copyright (C) 2020-2023 The ManaVerse Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef NET_EA_ADMINRECV_H -#define NET_EA_ADMINRECV_H - -#include "localconsts.h" - -namespace Net -{ - class MessageIn; -} // namespace Net - -namespace Ea -{ - namespace AdminRecv - { - void processKickAck(Net::MessageIn &msg); - } // namespace AdminRecv -} // namespace Ea - -#endif // NET_EA_ADMINRECV_H diff --git a/src/net/eathena/adminrecv.cpp b/src/net/eathena/adminrecv.cpp index 19895924d..fc9cb606b 100644 --- a/src/net/eathena/adminrecv.cpp +++ b/src/net/eathena/adminrecv.cpp @@ -19,8 +19,12 @@ * along with this program. If not, see . */ + #include "net/eathena/adminrecv.h" +#include "enums/resources/notifytypes.h" +#include "notifymanager.h" + #include "logger.h" #include "net/messagein.h" @@ -79,4 +83,12 @@ void AdminRecv::processAccountStats(Net::MessageIn &msg) msg.readInt16("zero"); } +void AdminRecv::processKickAck(Net::MessageIn &msg) +{ + if (msg.readInt8("flag") == 0) + NotifyManager::notify(NotifyTypes::KICK_FAIL); + else + NotifyManager::notify(NotifyTypes::KICK_SUCCEED); +} + } // namespace EAthena diff --git a/src/net/eathena/adminrecv.h b/src/net/eathena/adminrecv.h index 1dc2b13b5..6a660b18a 100644 --- a/src/net/eathena/adminrecv.h +++ b/src/net/eathena/adminrecv.h @@ -32,6 +32,7 @@ namespace EAthena namespace AdminRecv { void processAdminGetLoginAck(Net::MessageIn &msg); + void processKickAck(Net::MessageIn &msg); void processSetTileType(Net::MessageIn &msg); void processAccountStats(Net::MessageIn &msg); } // namespace AdminRecv diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 94290cb3f..f52402c9d 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -25,7 +25,6 @@ #include "net/packetinfo.h" -#include "net/ea/adminrecv.h" #include "net/ea/beingrecv.h" #include "net/ea/buysellrecv.h" #include "net/ea/charserverrecv.h" diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc index 2a8e26264..b93e9d09d 100644 --- a/src/net/eathena/packetsin.inc +++ b/src/net/eathena/packetsin.inc @@ -94,7 +94,7 @@ packet(SMSG_MAP_NOT_FOUND, 0x0840, -1, &GeneralRecv::processMap // map server, unknown versions packet(SMSG_ADMIN_GET_LOGIN_ACK, 0x01e0, 30, &AdminRecv::processAdminGetLoginAck, 0); -packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 3, &Ea::AdminRecv::processKickAck, 0); +packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 3, &AdminRecv::processKickAck, 0); packet(SMSG_ADMIN_SET_TILE_TYPE, 0x0192, 24, &AdminRecv::processSetTileType, 0); packet(SMSG_BATTLE_BEGINS, 0x08df, 50, &BattleGroundRecv::processBattleBegins, 0); packet(SMSG_BATTLE_JOINED, 0x08d9, 30, &BattleGroundRecv::processBattleJoined, 0); diff --git a/src/net/tmwa/adminrecv.cpp b/src/net/tmwa/adminrecv.cpp new file mode 100644 index 000000000..58ee1b175 --- /dev/null +++ b/src/net/tmwa/adminrecv.cpp @@ -0,0 +1,45 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2020 The ManaPlus Developers + * Copyright (C) 2020-2023 The ManaVerse Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "net/tmwa/adminrecv.h" + +#include "notifymanager.h" + +#include "enums/resources/notifytypes.h" + +#include "net/messagein.h" + +#include "debug.h" + +namespace TmwAthena +{ + +void AdminRecv::processKickAck(Net::MessageIn &msg) +{ + if (msg.readInt32("account id") == 0) + NotifyManager::notify(NotifyTypes::KICK_FAIL); + else + NotifyManager::notify(NotifyTypes::KICK_SUCCEED); +} + +} // namespace TmwAthena diff --git a/src/net/tmwa/adminrecv.h b/src/net/tmwa/adminrecv.h new file mode 100644 index 000000000..616e786e1 --- /dev/null +++ b/src/net/tmwa/adminrecv.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2020 The ManaPlus Developers + * Copyright (C) 2020-2023 The ManaVerse Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NET_TMWA_ADMINRECV_H +#define NET_TMWA_ADMINRECV_H + +#include "localconsts.h" + +namespace Net +{ + class MessageIn; +} // namespace Net + +namespace TmwAthena +{ + namespace AdminRecv + { + void processKickAck(Net::MessageIn &msg); + } // namespace AdminRecv +} // namespace TmwAthena + +#endif // NET_TMWA_ADMINRECV_H diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 0fec580a6..f070e1cf3 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -27,7 +27,6 @@ #include "net/packetinfo.h" -#include "net/ea/adminrecv.h" #include "net/ea/beingrecv.h" #include "net/ea/buysellrecv.h" #include "net/ea/charserverrecv.h" @@ -43,6 +42,7 @@ #include "net/ea/skillrecv.h" #include "net/ea/traderecv.h" +#include "net/tmwa/adminrecv.h" #include "net/tmwa/beingrecv.h" #include "net/tmwa/buysellrecv.h" #include "net/tmwa/charserverrecv.h" diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc index dbfdbd494..47f87c768 100644 --- a/src/net/tmwa/packetsin.inc +++ b/src/net/tmwa/packetsin.inc @@ -21,7 +21,7 @@ * along with this program. If not, see . */ -packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &Ea::AdminRecv::processKickAck, 0); +packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &AdminRecv::processKickAck, 0); packet(SMSG_BEING_ACTION, 0x008a, 29, &Ea::BeingRecv::processBeingAction, 0); packet(SMSG_BEING_CHANGE_DIRECTION, 0x009c, 9, &BeingRecv::processBeingChangeDirection, 0); packet(SMSG_BEING_CHANGE_LOOKS, 0x00c3, 8, &BeingRecv::processBeingChangeLook, 0); -- cgit v1.2.3-70-g09d2