diff options
author | MeshCollider <dobsonsa68@gmail.com> | 2018-10-16 18:19:40 +1300 |
---|---|---|
committer | MeshCollider <dobsonsa68@gmail.com> | 2018-11-06 12:35:07 +1300 |
commit | 13fe258e91e7a92326aedf151c571994166a06d4 (patch) | |
tree | 1375cd8bad53a37fa251095677d43cb0820648af /src/util | |
parent | 1ba5583646e3a64ebae4fcda3c498292998a6d5d (diff) |
Error if rpcpassword in conf contains a hash character
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/system.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index 4f5dd2d6e9..f6f36c2238 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -826,8 +826,10 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect std::string::size_type pos; int linenr = 1; while (std::getline(stream, str)) { + bool used_hash = false; if ((pos = str.find('#')) != std::string::npos) { str = str.substr(0, pos); + used_hash = true; } const static std::string pattern = " \t\r\n"; str = TrimString(str, pattern); @@ -840,6 +842,10 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect } else if ((pos = str.find('=')) != std::string::npos) { std::string name = prefix + TrimString(str.substr(0, pos), pattern); std::string value = TrimString(str.substr(pos + 1), pattern); + if (used_hash && name == "rpcpassword") { + error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr); + return false; + } options.emplace_back(name, value); } else { error = strprintf("parse error on line %i: %s", linenr, str); |