Skip to content

Commit a31a1ce

Browse files
committed
Merge bitcoin/bitcoin#21907: wallet: Do not iterate a directory if having an error while accessing it
29c9e2c wallet: Do not iterate a directory if having an error while accessing it (Hennadii Stepanov) Pull request description: On Windows when `ListDatabases` tries to iterate any system folder, e.g., "System Volume Information", it falls into an infinite loop. This PR fixes this bug. Now the `debug.log` contains: ``` 2021-05-12T09:07:53Z ListDatabases: Access is denied D:/System Volume Information -- skipping. ``` An easy way to reproduce the bug and test this PR is to pass the `-walletdir=D:\` command-line option, and run the `listwalletdir` RPC, or File -> Open Wallet in the GUI menu. Fixes #20081. Fixes #21136. Fixes #21904. Also https://bitcoin.stackexchange.com/questions/99243/listwalletdir-access-is-denied-d-system-volume-information ACKs for top commit: prayank23: ACK bitcoin/bitcoin@29c9e2c promag: Code review ACK 29c9e2c. meshcollider: Code review ACK 29c9e2c Tree-SHA512: b851c88e6d09626f4cb81acc2fa59a563b2aee64582963285715bf785c64b872e8bf738aa6b27bdbaf4c3e5c8565c2dc2c802135f9aa1f48b4b913435bc5d793
2 parents 386ba92 + 29c9e2c commit a31a1ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wallet/db.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
1818

1919
for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
2020
if (ec) {
21-
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
21+
if (fs::is_directory(*it)) {
22+
it.no_push();
23+
LogPrintf("%s: %s %s -- skipping.\n", __func__, ec.message(), it->path().string());
24+
} else {
25+
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
26+
}
2227
continue;
2328
}
2429

0 commit comments

Comments
 (0)