From de55d49c727d44a98170d0441624caf2bf9c8486 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 5 Jun 2022 20:17:31 +0200 Subject: [PATCH] Fix motd undef behavior Conditional jump or move depends on uninitialised value(s) at 0x2158DA: int IServer::SendPackMsg(CNetMsg_Sv_Motd*, int, int) (server.h:73) by 0x1FE02F: CGameContext::SendMotd(int) (gamecontext.cpp:538) by 0x20A874: CGameContext::ConchainSpecialMotdupdate(IConsole::IResult*, void*, void (*)(IConsole::IResult*, void*), void*) (gamecontext.cpp:3124) by 0x145A23: CConsole::Con_Chain(IConsole::IResult*, void*) (console.cpp:1202) by 0x132086: CConsole::ExecuteLineStroked(int, char const*, int, bool) (console.cpp:528) by 0x1323A7: CConsole::ExecuteLine(char const*, int, bool) (console.cpp:582) by 0x1326B1: CConsole::ExecuteFile(char const*, int, bool, int) (console.cpp:625) by 0x1C60E9: main (server.cpp:3874) Uninitialised value was created by a heap allocation at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x1C5900: CreateServer() (server.cpp:3755) by 0x1C5C4C: main (server.cpp:3818) --- memcheck.supp | 12 ------------ src/engine/server/server.cpp | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/memcheck.supp b/memcheck.supp index f53de143e..d8dad7979 100644 --- a/memcheck.supp +++ b/memcheck.supp @@ -1,15 +1,3 @@ -{ - Motd - Memcheck:Cond - fun:_ZN7IServer11SendPackMsgI15CNetMsg_Sv_MotdLi0EEEiPT_ii - fun:_ZN12CGameContext8SendMotdEi - fun:_ZN12CGameContext25ConchainSpecialMotdupdateEPN8IConsole7IResultEPvPFvS2_S3_ES3_ - fun:_ZN8CConsole9Con_ChainEPN8IConsole7IResultEPv - fun:_ZN8CConsole18ExecuteLineStrokedEiPKcib - fun:_ZN8CConsole11ExecuteLineEPKcib - fun:_ZN8CConsole11ExecuteFileEPKcibi - fun:main -} { DemoRecorderWrite Memcheck:Param diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 8dcf6e44a..fd4c978f0 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -723,7 +723,7 @@ int CServer::Port() const int CServer::MaxClients() const { - return m_NetServer.MaxClients(); + return m_RunServer == UNINITIALIZED ? 0 : m_NetServer.MaxClients(); } int CServer::ClientCount() const