diff options
| author | vaxerski <vaxry@vaxry.net> | 2023-12-20 13:07:12 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2023-12-20 13:07:12 +0100 |
| commit | b4f4bd38e8a0d9afd30231cf999e73548bef5760 (patch) | |
| tree | ee2729192095bfef3b47e5b640ca820807787f16 /src | |
| parent | d1b8a63a8ef1d7258d49854d2256fa9b99fd99bc (diff) | |
configmanager: set a limit to config variable substitutions
fixes #4198
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigManager.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 8afa627d..8ecfa87b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1478,7 +1478,10 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equalsPlace) { auto dollarPlace = line.find_first_of('$', equalsPlace); + int times = 0; + while (dollarPlace != std::string::npos) { + times++; const auto STRAFTERDOLLAR = line.substr(dollarPlace + 1); bool found = false; @@ -1501,6 +1504,13 @@ void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equals } dollarPlace = line.find_first_of('$', dollarPlace + 1); + + if (times > 256 /* arbitrary limit */) { + line = ""; + parseError = "Maximum variable recursion limit hit. Evaluating the line led to too many variable substitutions."; + Debug::log(ERR, "Variable recursion limit hit in configmanager"); + break; + } } } |
