diff options
author | nthumann <me@n-thumann.de> | 2021-08-04 12:07:31 +0200 |
---|---|---|
committer | nthumann <me@n-thumann.de> | 2021-08-04 12:24:53 +0200 |
commit | 6bb54708e6457f21596793a7149dc6dfea1dc871 (patch) | |
tree | 3d4c34529bc3034504d505be52b807c18900584a /src | |
parent | eaf09bda4ab21f79f89822d2c6fa3d7a3ce57b0d (diff) | |
download | bitcoin-6bb54708e6457f21596793a7149dc6dfea1dc871.tar.xz |
util: Check if specified config file cannot be opened
Diffstat (limited to 'src')
-rw-r--r-- | src/util/system.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index 258ba2f235..85a23731a2 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -904,6 +904,11 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME); fsbridge::ifstream stream(GetConfigFile(confPath)); + // not ok to have a config file specified that cannot be opened + if (IsArgSet("-conf") && !stream.good()) { + error = strprintf("specified config file \"%s\" could not be opened.", confPath); + return false; + } // ok to not have a config file if (stream.good()) { if (!ReadConfigStream(stream, confPath, error, ignore_invalid_keys)) { |