From ac2b7d70ddcb3d125d86256a17d1d65e1e855271 Mon Sep 17 00:00:00 2001 From: John <63141077+AconiteX@users.noreply.github.com> Date: Sun, 3 Apr 2022 06:34:03 -0400 Subject: [PATCH] Stopgap fix for stoi crash in ext admin level req --- .../src/shared/AdminAccountManager.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp index 2118aa18..4a1f5a6a 100755 --- a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp +++ b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp @@ -77,7 +77,20 @@ int AdminAccountManager::getAdminLevel(const std::string & account) std::ostringstream postBuffer; postBuffer << "user_name=" << account << "&secretKey=" << ConfigServerUtility::getExternalAdminLevelsSecretKey(); std::string response = webAPI::simplePost(ConfigServerUtility::getExternalAdminLevelsURL(), std::string(postBuffer.str()), ""); - level = std::stoi(response); + // aconite 4/3/22 + // stoi inconsistently throws an invalid argument exception from this request + // which causes the login and/or game server to crash on an auth or /setGod; + // this is a temporary patch to safeguard against that until this can be further evaluated + try + { + int newLevel = std::stoi(response); + if(newLevel != 0) + { + level = newLevel; + } + } + catch(std::invalid_argument const& ex) {} + catch(std::out_of_range const& ex) {} return level; }