mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 08:44:02 +02:00
Merge #14494: Error if # is used in rpcpassword in conf
0385109444Add test for rpcpassword hash error (MeshCollider)13fe258e91Error if rpcpassword in conf contains a hash character (MeshCollider) Pull request description: Fixes #13143 now #13482 was merged Tree-SHA512: e7d00c8df1657f6b8d0eee1e06b9ce2b1b0a2de487377699382c1b057836e1571dac313ca878b5877c862f0461ba789a50b239d2a9f34accd8a6321f126e3d2a
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user