From e3c86dfd7e16ad594eae031d19c629dc37d4515d Mon Sep 17 00:00:00 2001 From: Edo Date: Wed, 15 Mar 2023 18:50:23 +0000 Subject: [PATCH] [RCon]: Address rare crash (#834) --- src/Components/Modules/NetworkDebug.cpp | 21 +++++++++++++++++++++ src/Components/Modules/NetworkDebug.hpp | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/Components/Modules/NetworkDebug.cpp b/src/Components/Modules/NetworkDebug.cpp index 97c8bdfa..3f101a57 100644 --- a/src/Components/Modules/NetworkDebug.cpp +++ b/src/Components/Modules/NetworkDebug.cpp @@ -35,6 +35,24 @@ namespace Components Game::FS_FreeFile(file); } + int NetworkDebug::I_stricmp_Stub(const char* s0, const char* s1) + { + assert(s0); + assert(s1); + + if (!s0) + { + return -1; + } + + if (!s1) + { + return 1; + } + + return Utils::Hook::Call(0x426080)(s0, s1, std::numeric_limits::max()); // I_strnicmp + } + NetworkDebug::NetworkDebug() { #ifdef _DEBUG @@ -42,6 +60,9 @@ namespace Components Command::Add("parseBadPacket", CL_ParseBadPacket_f); #endif + // Address "race" condition where commands received from RCon can be null + Utils::Hook(0x6094DA, I_stricmp_Stub, HOOK_CALL).install()->quick(); // Cmd_ExecuteServerString + // Backport updates from IW5 Utils::Hook::Set(0x45D112, "CL_PacketEvent - ignoring illegible message\n"); } diff --git a/src/Components/Modules/NetworkDebug.hpp b/src/Components/Modules/NetworkDebug.hpp index 34ec8344..48745360 100644 --- a/src/Components/Modules/NetworkDebug.hpp +++ b/src/Components/Modules/NetworkDebug.hpp @@ -11,5 +11,7 @@ namespace Components static void CL_ParseServerMessage_Hk(Game::msg_t* msg); static void CL_ParseBadPacket_f(); + + static int I_stricmp_Stub(const char* s0, const char* s1); }; }