Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-09-10 22:39:23 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-09-10 22:39:23 +0300
commit42c2a4d09add1c0e1c37de0c4036a5ba2a3d6e52 (patch)
tree1d2573fdc188ffdd54766ce39f74b37996135415 /include/llfio/v2.0/detail
parenta302c5ab2f601c0116fb62c6b21dec4a143550e9 (diff)
Fix issue #27 Enumerating empty directories causes infinite loop on Windows
Diffstat (limited to 'include/llfio/v2.0/detail')
-rw-r--r--include/llfio/v2.0/detail/impl/windows/directory_handle.ipp19
1 files changed, 9 insertions, 10 deletions
diff --git a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
index 8b6dd9b5..e8bbeaee 100644
--- a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
@@ -318,9 +318,11 @@ result<directory_handle::buffers_type> directory_handle::read(io_request<buffers
}
} while(!done);
size_t n = 0;
- for(FILE_ID_FULL_DIR_INFORMATION *ffdi = buffer;; ffdi = reinterpret_cast<FILE_ID_FULL_DIR_INFORMATION *>(reinterpret_cast<uintptr_t>(ffdi) + ffdi->NextEntryOffset))
+ done = false;
+ for(FILE_ID_FULL_DIR_INFORMATION *ffdi = buffer; !done; ffdi = reinterpret_cast<FILE_ID_FULL_DIR_INFORMATION *>(reinterpret_cast<uintptr_t>(ffdi) + ffdi->NextEntryOffset))
{
size_t length = ffdi->FileNameLength / sizeof(wchar_t);
+ done = (ffdi->NextEntryOffset == 0);
if(length <= 2 && '.' == ffdi->FileName[0])
{
if(1 == length || '.' == ffdi->FileName[1])
@@ -352,15 +354,7 @@ result<directory_handle::buffers_type> directory_handle::read(io_request<buffers
item.stat.st_compressed = static_cast<unsigned int>((ffdi->FileAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0u);
item.stat.st_reparse_point = static_cast<unsigned int>((ffdi->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0u);
n++;
- if(ffdi->NextEntryOffset == 0u)
- {
- // Fill is complete
- req.buffers._resize(n);
- req.buffers._metadata = default_stat_contents;
- req.buffers._done = true;
- return std::move(req.buffers);
- }
- if(n >= req.buffers.size())
+ if(!done && n >= req.buffers.size())
{
// Fill is incomplete
req.buffers._metadata = default_stat_contents;
@@ -368,6 +362,11 @@ result<directory_handle::buffers_type> directory_handle::read(io_request<buffers
return std::move(req.buffers);
}
}
+ // Fill is complete
+ req.buffers._resize(n);
+ req.buffers._metadata = default_stat_contents;
+ req.buffers._done = true;
+ return std::move(req.buffers);
}
LLFIO_V2_NAMESPACE_END