From 749398cf3247e2d63f794ce6d02217f8aa07d811 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Mon, 9 Aug 2021 22:15:34 +0200 Subject: Skip the empty "last entry" in the `NtfsIndexEntries` iterator. Testing shows that there are NTFS filesystems that have a last index entry *without* a subnode (i.e. with no useful information at all). --- src/index.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.rs b/src/index.rs index f9769d9..6f8d18c 100644 --- a/src/index.rs +++ b/src/index.rs @@ -2,7 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later use crate::error::{NtfsError, Result}; -use crate::index_entry::{IndexEntryRange, IndexNodeEntryRanges, NtfsIndexEntry}; +use crate::index_entry::{ + IndexEntryRange, IndexNodeEntryRanges, NtfsIndexEntry, NtfsIndexEntryFlags, +}; use crate::indexes::NtfsIndexEntryType; use crate::structured_values::{NtfsIndexAllocation, NtfsIndexRoot}; use alloc::vec::Vec; @@ -136,8 +138,9 @@ where // has been fully iterated. self.inner_iterators.push(subnode_iter); self.following_entries.push(entry_range); - } else { - // There is no subnode, so our `entry` is next lexicographically. + } else if !entry.flags().contains(NtfsIndexEntryFlags::LAST_ENTRY) { + // There is no subnode, and this is not the empty "last entry", + // so our `entry` comes next lexicographically. break entry_range; } } else { -- cgit v1.2.3