From 0ad1c08c229f86eca807c61653ea0fd74ba9fe8c Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Wed, 11 Sep 2024 17:58:38 +0200 Subject: [PATCH] Fixes a bug where econ was exposed publicly when ec_bindaddr was set to localhost Also implements the original intention of 85f5e9c that is to disable econ if ec_binaddr is invalid. --- src/engine/shared/econ.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/shared/econ.cpp b/src/engine/shared/econ.cpp index 354e9eded..52305395a 100644 --- a/src/engine/shared/econ.cpp +++ b/src/engine/shared/econ.cpp @@ -70,18 +70,18 @@ void CEcon::Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan) } NETADDR BindAddr; - if(g_Config.m_EcBindaddr[0] == '\0') + if(g_Config.m_EcBindaddr[0] && net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) == 0) { - mem_zero(&BindAddr, sizeof(BindAddr)); + // got bindaddr + BindAddr.port = g_Config.m_EcPort; } - else if(net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) != 0) + else { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "The configured bindaddr '%s' cannot be resolved.", g_Config.m_Bindaddr); + str_format(aBuf, sizeof(aBuf), "The configured bindaddr '%s' cannot be resolved.", g_Config.m_EcBindaddr); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "econ", aBuf); + return; } - BindAddr.type = NETTYPE_ALL; - BindAddr.port = g_Config.m_EcPort; if(m_NetConsole.Open(BindAddr, pNetBan)) {