From 39db8fe25b819316b318ad508d7d99e178467d7a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 9 Jan 2019 15:07:32 +0100 Subject: [PATCH] Merge #15087: Error if rpcpassword contains hash in conf sections 8cff83124bcac936ecc6add6dca72b125a79a08f Error if rpcpassword contains hash in conf sections (MeshCollider) Pull request description: Fixes #15075 Tree-SHA512: 08ba2a2e9a7ea228fc0e0ff9aa76da1fecbe079e3b388304a28b6399e338a4b3a38b03ab03aca880e75f14a8d2ba75ceb31a385d7989cd66db5193a79f32c4e5 --- src/util/system.cpp | 2 +- test/functional/feature_config_args.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/system.cpp b/src/util/system.cpp index 8312706d48..574144451a 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -935,7 +935,7 @@ 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") { + if (used_hash && name.find("rpcpassword") != std::string::npos) { error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr); return false; } diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index 5124319f98..8a61cde8d7 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -43,6 +43,14 @@ class ConfArgsTest(BitcoinTestFramework): conf.write('server=1\nrpcuser=someuser\nrpcpassword=some#pass') 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') + with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: + conf.write('server=1\nrpcuser=someuser\nmain.rpcpassword=some#pass') + 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') + + with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: + conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass') + 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') + with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: conf.write('testnot.datadir=1\n[testnet]\n') self.restart_node(0)