From 26522d212b4b84ae4cbbdde8c7ab0ff55577a591 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 24 Jun 2020 12:21:25 -0300 Subject: [PATCH] only allow duplicates for certain options of the config --- src/util.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/util.cpp b/src/util.cpp index 82d705ea8..5d88aba88 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -627,10 +627,21 @@ void ReadConfigFile(const std::string& confPath, set setOptions; setOptions.insert("*"); + const vector allowed_duplicates = {"addnode", "connect", "rpcallowip"}; + set unique_options; + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { string strKey = string("-") + it->string_key; string strValue = it->value[0]; + + if (find(allowed_duplicates.begin(), allowed_duplicates.end(), it->string_key) == allowed_duplicates.end()) + { + if (!unique_options.insert(strKey).second) { + throw std::runtime_error(strprintf("Not allowed duplicated option %s found.", strKey)); + } + } + InterpretNegativeSetting(strKey, strValue); // Don't overwrite existing settings so command line settings override zcash.conf if (mapSettingsRet.count(strKey) == 0)