From 7b0b201d109b6240f114498fc1b94af9cb85f26e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 10 May 2021 21:45:18 +0300 Subject: wallet: Do not iterate a directory if having an error while accessing it This change prevents infinite looping for, for example, system folders on Windows. Github-Pull: #21907 Rebased-From: 29c9e2c2d2015ade47ed4497926363dea3f9c59b --- src/wallet/walletutil.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 04c2407a89..f8827604ba 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -63,7 +63,12 @@ std::vector ListWalletDir() for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) { if (ec) { - LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string()); + if (fs::is_directory(*it)) { + it.no_push(); + LogPrintf("%s: %s %s -- skipping.\n", __func__, ec.message(), it->path().string()); + } else { + LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string()); + } continue; } -- cgit v1.2.3