diff options
author | Colin Finck <colin@reactos.org> | 2021-07-21 21:20:52 +0300 |
---|---|---|
committer | Colin Finck <colin@reactos.org> | 2021-07-21 21:20:52 +0300 |
commit | c76c87e1cf3164da01e872f26e3160a1d80bdb7f (patch) | |
tree | 2ddb4358be0e9b38754feba52ecb1e2c85a5c49e /src | |
parent | b659b7861b19dde96819620c71bee883f23d3e13 (diff) |
Improve error reporting of `NtfsIndexRecord::validate_sizes`
Diffstat (limited to 'src')
-rw-r--r-- | src/error.rs | 10 | ||||
-rw-r--r-- | src/index_record.rs | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs index fa62d8e..1836be3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -76,8 +76,14 @@ pub enum NtfsError { expected: &'static [u8], actual: [u8; 4], }, - /// The NTFS index record at byte position {position:#010x} should have a maximum of {expected} bytes, but it indicates {actual} bytes - InvalidNtfsIndexSize { + /// The NTFS index record at byte position {position:#010x} indicates an allocated size of {expected} bytes, but the record only has a size of {actual} bytes + InvalidNtfsIndexAllocatedSize { + position: u64, + expected: u32, + actual: u32, + }, + /// The NTFS index record at byte position {position:#010x} indicates a used size of {expected} bytes, but only {actual} bytes are allocated + InvalidNtfsIndexUsedSize { position: u64, expected: u32, actual: u32, diff --git a/src/index_record.rs b/src/index_record.rs index 5b47aa1..b6120c1 100644 --- a/src/index_record.rs +++ b/src/index_record.rs @@ -131,7 +131,7 @@ impl<'n> NtfsIndexRecord<'n> { // the size defined for all index records of this index. let total_allocated_size = INDEX_RECORD_HEADER_SIZE + self.index_allocated_size(); if total_allocated_size > index_record_size { - return Err(NtfsError::InvalidNtfsIndexSize { + return Err(NtfsError::InvalidNtfsIndexAllocatedSize { position: self.record.position(), expected: index_record_size, actual: total_allocated_size, @@ -142,7 +142,7 @@ impl<'n> NtfsIndexRecord<'n> { // larger than the total allocated size. let total_used_size = INDEX_RECORD_HEADER_SIZE + self.index_used_size(); if total_used_size > total_allocated_size { - return Err(NtfsError::InvalidNtfsIndexSize { + return Err(NtfsError::InvalidNtfsIndexUsedSize { position: self.record.position(), expected: total_allocated_size, actual: total_used_size, |