Skip to content

Commit 13fe258

Browse files
committed
Error if rpcpassword in conf contains a hash character
1 parent 1ba5583 commit 13fe258

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util/system.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,10 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect
826826
std::string::size_type pos;
827827
int linenr = 1;
828828
while (std::getline(stream, str)) {
829+
bool used_hash = false;
829830
if ((pos = str.find('#')) != std::string::npos) {
830831
str = str.substr(0, pos);
832+
used_hash = true;
831833
}
832834
const static std::string pattern = " \t\r\n";
833835
str = TrimString(str, pattern);
@@ -840,6 +842,10 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect
840842
} else if ((pos = str.find('=')) != std::string::npos) {
841843
std::string name = prefix + TrimString(str.substr(0, pos), pattern);
842844
std::string value = TrimString(str.substr(pos + 1), pattern);
845+
if (used_hash && name == "rpcpassword") {
846+
error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr);
847+
return false;
848+
}
843849
options.emplace_back(name, value);
844850
} else {
845851
error = strprintf("parse error on line %i: %s", linenr, str);

0 commit comments

Comments
 (0)