Skip to content

Commit 8cff831

Browse files
committed
Error if rpcpassword contains hash in conf sections
1 parent 031e3a3 commit 8cff831

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect
865865
} else if ((pos = str.find('=')) != std::string::npos) {
866866
std::string name = prefix + TrimString(str.substr(0, pos), pattern);
867867
std::string value = TrimString(str.substr(pos + 1), pattern);
868-
if (used_hash && name == "rpcpassword") {
868+
if (used_hash && name.find("rpcpassword") != std::string::npos) {
869869
error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr);
870870
return false;
871871
}

test/functional/feature_config_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ def test_config_file_parser(self):
3333
conf.write('server=1\nrpcuser=someuser\nrpcpassword=some#pass')
3434
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided')
3535

36+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
37+
conf.write('server=1\nrpcuser=someuser\nmain.rpcpassword=some#pass')
38+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided')
39+
40+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
41+
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
42+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
43+
3644
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
3745
conf.write('testnot.datadir=1\n[testnet]\n')
3846
self.restart_node(0)

0 commit comments

Comments
 (0)