aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-11-12 15:20:30 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-11-12 15:23:27 +0100
commit90c0b6aca2da0e15bd0575d583a167723f9cebed (patch)
treef062367f88581617466b1b60dc0fd219768a03f2 /src
parent5cdfd72b179d91ce4db085375fd6cdfa3cbd9d41 (diff)
parent0385109444646561a718f34ae437b7e0e4d4d5bc (diff)
Merge #14494: Error if # is used in rpcpassword in conf
0385109444646561a718f34ae437b7e0e4d4d5bc Add test for rpcpassword hash error (MeshCollider) 13fe258e91e7a92326aedf151c571994166a06d4 Error if rpcpassword in conf contains a hash character (MeshCollider) Pull request description: Fixes #13143 now #13482 was merged Tree-SHA512: e7d00c8df1657f6b8d0eee1e06b9ce2b1b0a2de487377699382c1b057836e1571dac313ca878b5877c862f0461ba789a50b239d2a9f34accd8a6321f126e3d2a
Diffstat (limited to 'src')
-rw-r--r--src/util/system.cpp6
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);