From e02da5ba4ac71bddf04255ea76509aeebfb3ef2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 03:23:51 +0000 Subject: [PATCH 2/5] Harden inspect message handling Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com> --- common/shareddb.cpp | 2 +- libs/perlbind/include/perlbind/function.h | 2 +- zone/client_packet.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 0ef0cbe4e..97807ef39 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1853,7 +1853,7 @@ void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMes return; } - memcpy(s, e.inspect_message.c_str(), sizeof(InspectMessage_Struct)); + strn0cpy(s->text, e.inspect_message.c_str(), sizeof(s->text)); } void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* s) diff --git a/libs/perlbind/include/perlbind/function.h b/libs/perlbind/include/perlbind/function.h index 2d4455a9b..89f26fec9 100644 --- a/libs/perlbind/include/perlbind/function.h +++ b/libs/perlbind/include/perlbind/function.h @@ -74,7 +74,7 @@ struct function : public function_base, function_traits std::string get_signature() const override { - return util::type_name::str(); + return util::type_name::str() + "(" + util::type_name::str() + ")"; }; bool is_compatible(xsub_stack& stack) const override diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 231d442e1..e14cd85ef 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9062,10 +9062,10 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) } } - auto message = (InspectMessage_Struct *) insr->text; - auto inspect_message = GetInspectMessage(); + auto message = reinterpret_cast(insr->text); + auto &inspect_message = GetInspectMessage(); - memcpy(&inspect_message, message, sizeof(InspectMessage_Struct)); + strn0cpy(inspect_message.text, message->text, sizeof(inspect_message.text)); database.SaveCharacterInspectMessage(CharacterID(), &inspect_message); if ( @@ -9084,9 +9084,9 @@ void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) return; } - InspectMessage_Struct* newmessage = (InspectMessage_Struct*)app->pBuffer; - InspectMessage_Struct& playermessage = GetInspectMessage(); - memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct)); + auto *newmessage = reinterpret_cast(app->pBuffer); + auto &playermessage = GetInspectMessage(); + strn0cpy(playermessage.text, newmessage->text, sizeof(playermessage.text)); database.SaveCharacterInspectMessage(CharacterID(), &playermessage); } From 106fb2aeeae2c0c799fdcf3f3977973bd425f0ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 03:37:32 +0000 Subject: [PATCH 3/5] Add inspect message regression test Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com> --- tests/CMakeLists.txt | 1 + tests/inspect_message_test.h | 52 ++++++++++++++++++++++++++++++++++++ tests/main.cpp | 2 ++ 3 files changed, 55 insertions(+) create mode 100644 tests/inspect_message_test.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6ed82f5b8..55812f309 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,7 @@ SET(tests_headers fixed_memory_variable_test.h hextoi_32_64_test.h ipc_mutex_test.h + inspect_message_test.h memory_mapped_file_test.h string_util_test.h skills_util_test.h diff --git a/tests/inspect_message_test.h b/tests/inspect_message_test.h new file mode 100644 index 000000000..774d65674 --- /dev/null +++ b/tests/inspect_message_test.h @@ -0,0 +1,52 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) + + 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; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H +#define __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H + +#include +#include +#include "cppunit/cpptest.h" +#include "../common/eq_packet_structs.h" +#include "../common/strings.h" + +class InspectMessageTest : public Test::Suite { + typedef void(InspectMessageTest::*TestFunction)(void); +public: + InspectMessageTest() { + TEST_ADD(InspectMessageTest::CopyEnsuresNullTermination); + } + + ~InspectMessageTest() { + } + +private: + void CopyEnsuresNullTermination() { + InspectMessage_Struct incoming{}; + InspectMessage_Struct stored{}; + + std::string long_text(300, 'A'); + strn0cpy(incoming.text, long_text.c_str(), sizeof(incoming.text)); + strn0cpy(stored.text, incoming.text, sizeof(stored.text)); + + TEST_ASSERT_EQUALS(stored.text[sizeof(stored.text) - 1], '\0'); + TEST_ASSERT_EQUALS(std::strlen(stored.text), sizeof(stored.text) - 1); + } +}; + +#endif diff --git a/tests/main.cpp b/tests/main.cpp index 9c9af40c9..67c8a2441 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -28,6 +28,7 @@ #include "fixed_memory_variable_test.h" #include "atobool_test.h" #include "hextoi_32_64_test.h" +#include "inspect_message_test.h" #include "string_util_test.h" #include "data_verification_test.h" #include "skills_util_test.h" @@ -52,6 +53,7 @@ int main() tests.add(new FixedMemoryVariableHashTest()); tests.add(new atoboolTest()); tests.add(new hextoi_32_64_Test()); + tests.add(new InspectMessageTest()); tests.add(new StringUtilTest()); tests.add(new DataVerificationTest()); tests.add(new SkillsUtilsTest()); From 650cd53fbd6c7236b1ef1377016c88febb21ef53 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 03:38:43 +0000 Subject: [PATCH 4/5] Tweak inspect message test Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com> --- tests/inspect_message_test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/inspect_message_test.h b/tests/inspect_message_test.h index 774d65674..f95cd951c 100644 --- a/tests/inspect_message_test.h +++ b/tests/inspect_message_test.h @@ -6,7 +6,7 @@ the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which + but WITHOUT ANY WARRANTY except by those people who sell it, which are required to give you total support for your newly bought product; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -40,7 +40,7 @@ private: InspectMessage_Struct incoming{}; InspectMessage_Struct stored{}; - std::string long_text(300, 'A'); + std::string long_text(sizeof(incoming.text) + 44, 'A'); strn0cpy(incoming.text, long_text.c_str(), sizeof(incoming.text)); strn0cpy(stored.text, incoming.text, sizeof(stored.text)); From 0f10ece0e77ed7737c719fdf4e37a5490c96721d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 04:23:22 +0000 Subject: [PATCH 5/5] Remove inspect message test Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com> --- tests/CMakeLists.txt | 1 - tests/inspect_message_test.h | 52 ------------------------------------ tests/main.cpp | 2 -- 3 files changed, 55 deletions(-) delete mode 100644 tests/inspect_message_test.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 55812f309..6ed82f5b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,7 +13,6 @@ SET(tests_headers fixed_memory_variable_test.h hextoi_32_64_test.h ipc_mutex_test.h - inspect_message_test.h memory_mapped_file_test.h string_util_test.h skills_util_test.h diff --git a/tests/inspect_message_test.h b/tests/inspect_message_test.h deleted file mode 100644 index f95cd951c..000000000 --- a/tests/inspect_message_test.h +++ /dev/null @@ -1,52 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) - - 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; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people who sell it, which - are required to give you total support for your newly bought product; - 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, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H -#define __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H - -#include -#include -#include "cppunit/cpptest.h" -#include "../common/eq_packet_structs.h" -#include "../common/strings.h" - -class InspectMessageTest : public Test::Suite { - typedef void(InspectMessageTest::*TestFunction)(void); -public: - InspectMessageTest() { - TEST_ADD(InspectMessageTest::CopyEnsuresNullTermination); - } - - ~InspectMessageTest() { - } - -private: - void CopyEnsuresNullTermination() { - InspectMessage_Struct incoming{}; - InspectMessage_Struct stored{}; - - std::string long_text(sizeof(incoming.text) + 44, 'A'); - strn0cpy(incoming.text, long_text.c_str(), sizeof(incoming.text)); - strn0cpy(stored.text, incoming.text, sizeof(stored.text)); - - TEST_ASSERT_EQUALS(stored.text[sizeof(stored.text) - 1], '\0'); - TEST_ASSERT_EQUALS(std::strlen(stored.text), sizeof(stored.text) - 1); - } -}; - -#endif diff --git a/tests/main.cpp b/tests/main.cpp index 67c8a2441..9c9af40c9 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -28,7 +28,6 @@ #include "fixed_memory_variable_test.h" #include "atobool_test.h" #include "hextoi_32_64_test.h" -#include "inspect_message_test.h" #include "string_util_test.h" #include "data_verification_test.h" #include "skills_util_test.h" @@ -53,7 +52,6 @@ int main() tests.add(new FixedMemoryVariableHashTest()); tests.add(new atoboolTest()); tests.add(new hextoi_32_64_Test()); - tests.add(new InspectMessageTest()); tests.add(new StringUtilTest()); tests.add(new DataVerificationTest()); tests.add(new SkillsUtilsTest());