From e8f79e695ff8a72776c68eb4ff37b99ce4921673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Divi=C5=A1?= Date: Tue, 17 Nov 2026 02:11:30 +0100 Subject: [PATCH] Reject index entries shorter than the entry header An index_entry_length below INDEX_ENTRY_HEADER_SIZE passed validate_size. The entry slice was then truncated below the header, so later header field accesses went out of bounds, and a length of zero kept the entry iterator from advancing. Co-Authored-By: Claude Fable 5.2 --- src/index_entry.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index_entry.rs b/src/index_entry.rs index e55b77b..a42e4c7 100644 --- a/src/index_entry.rs +++ b/src/index_entry.rs @@ -284,6 +284,17 @@ where }); } + // An entry shorter than its own header would truncate the slice below the + // header (out-of-bounds access to the header fields later on), and a + // length of zero would keep the entry iterator from ever advancing. + if (self.index_entry_length() as usize) < INDEX_ENTRY_HEADER_SIZE { + return Err(NtfsError::InvalidIndexEntrySize { + position: self.position, + expected: INDEX_ENTRY_HEADER_SIZE as u16, + actual: self.index_entry_length(), + }); + } + if self.index_entry_length() as usize > self.slice.len() { return Err(NtfsError::InvalidIndexEntrySize { position: self.position,