From e82c32baab4d5a0f096305da033c8495bee35137 Mon Sep 17 00:00:00 2001 From: Foxar Date: Sun, 29 Nov 2020 17:01:48 +0100 Subject: [PATCH] Fix #6598: Added company id check for connect console command. --- src/console_cmds.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 857dc61ad9576..b722eb87d7cc7 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -919,6 +919,12 @@ DEF_CONSOLE_CMD(ConNetworkConnect) IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip); if (company != nullptr) { join_as = (CompanyID)atoi(company); + IConsolePrintF(CC_DEFAULT, "Connecting as company id %s ...", company); + /* Check if we have a valid company id! */ + if(!Company::IsValidID(join_as) && join_as != COMPANY_SPECTATOR){ + IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES); + return true; + } IConsolePrintF(CC_DEFAULT, " company-no: %d", join_as); /* From a user pov 0 is a new company, internally it's different and all