util: Disallow network-qualified command line options

Previously these were allowed but ignored.
This commit is contained in:
Russell Yanofsky
2019-12-19 16:27:15 -05:00
parent 6677be64f6
commit 900d8f6f70
4 changed files with 42 additions and 16 deletions

View File

@@ -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