rpc: Validate -rpcauth arguments

This commit is contained in:
João Barbosa
2020-11-23 12:00:50 +00:00
parent d37c813a43
commit 46001323b1
2 changed files with 13 additions and 3 deletions

View File

@@ -253,11 +253,14 @@ static bool InitRPCAuthentication()
if (gArgs.GetArg("-rpcauth","") != "")
{
LogPrintf("Using rpcauth authentication.\n");
for (std::string rpcauth : gArgs.GetArgs("-rpcauth")) {
for (const std::string& rpcauth : gArgs.GetArgs("-rpcauth")) {
std::vector<std::string> fields;
boost::split(fields, rpcauth, boost::is_any_of(":$"));
if (fields.size() == 3) {
g_rpcauth.push_back(fields);
} else {
LogPrintf("Invalid -rpcauth argument.\n");
return false;
}
}
}