From 4ce38ba7258229d31701e69ede6a84d30f042974 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 25 Feb 2024 19:56:58 +0100 Subject: [PATCH] Engine: close RCON socket on password hashing failure Must also be closed here --- src/engine/server/sv_rcon.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/engine/server/sv_rcon.cpp b/src/engine/server/sv_rcon.cpp index 533dfa32..fdac5d5d 100644 --- a/src/engine/server/sv_rcon.cpp +++ b/src/engine/server/sv_rcon.cpp @@ -98,6 +98,15 @@ void CRConServer::Init(void) //----------------------------------------------------------------------------- void CRConServer::Shutdown(void) { + if (!m_bInitialized) + { + // If we aren't initialized, we shouldn't have any connections at all. + Assert(!m_Socket.GetAcceptedSocketCount(), "Accepted connections while RCON server isn't initialized!"); + Assert(!m_Socket.IsListening(), "Listen socket active while RCON server isn't initialized!"); + + return; + } + m_bInitialized = false; const int nConnCount = m_Socket.GetAcceptedSocketCount(); @@ -178,6 +187,12 @@ bool CRConServer::SetPassword(const char* pszPassword) if (nHashRet != 0) { Error(eDLL_T::SERVER, 0, "SHA-512 algorithm failed on RCON password [%i]\n", nHashRet); + + if (m_Socket.IsListening()) + { + m_Socket.CloseListenSocket(); + } + return false; }