aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2019-12-19 16:27:15 -0500
committerRussell Yanofsky <russ@yanofsky.org>2019-12-19 16:27:15 -0500
commit900d8f6f70859f528e84c5c38d0332f81d19df55 (patch)
tree77a9236d14f792e881aee790e4cebd7425f1a7cf /src/util
parent6677be64f69b3d6f60f5a675ff9746def27a2de8 (diff)
util: Disallow network-qualified command line options
Previously these were allowed but ignored.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/system.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index d99a87a9f2..5587764c58 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -311,21 +311,18 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
std::string section;
util::SettingsValue value = InterpretOption(section, key, val);
Optional<unsigned int> flags = GetArgFlags('-' + key);
- if (flags) {
- if (!CheckValid(key, value, *flags, error)) {
- return false;
- }
- // Weird behavior preserved for backwards compatibility: command
- // line options with section prefixes are allowed but ignored. It
- // would be better if these options triggered the Invalid parameter
- // error below.
- if (section.empty()) {
- m_settings.command_line_options[key].push_back(value);
- }
- } else {
- error = strprintf("Invalid parameter -%s", key);
+
+ // Unknown command line options and command line options with dot
+ // characters (which are returned from InterpretOption with nonempty
+ // section strings) are not valid.
+ if (!flags || !section.empty()) {
+ error = strprintf("Invalid parameter %s", argv[i]);
return false;
}
+
+ if (!CheckValid(key, value, *flags, error)) return false;
+
+ m_settings.command_line_options[key].push_back(value);
}
// we do not allow -includeconf from command line