Skip to content

Commit 6bb5470

Browse files
committed
util: Check if specified config file cannot be opened
1 parent eaf09bd commit 6bb5470

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/util/system.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,11 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
904904
const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
905905
fsbridge::ifstream stream(GetConfigFile(confPath));
906906

907+
// not ok to have a config file specified that cannot be opened
908+
if (IsArgSet("-conf") && !stream.good()) {
909+
error = strprintf("specified config file \"%s\" could not be opened.", confPath);
910+
return false;
911+
}
907912
// ok to not have a config file
908913
if (stream.good()) {
909914
if (!ReadConfigStream(stream, confPath, error, ignore_invalid_keys)) {

0 commit comments

Comments
 (0)