Redesigned the INDEX_ROOT consistency checks

By ordering the values from smallest to biggest, there is less chance
to be caught by an arithmetic overflow.
edge.strict_endians^2
Jean-Pierre André 2021-07-19 09:23:23 +02:00
parent 81725f6a54
commit bb4456d339
1 changed files with 7 additions and 8 deletions

View File

@ -3496,16 +3496,15 @@ int ntfs_attr_consistent(const ATTR_RECORD *a, const MFT_REF mref)
if (a->non_resident
|| (le32_to_cpu(a->value_length)
< offsetof(INDEX_ROOT, index.reserved))
|| (le32_to_cpu(ir->index.entries_offset)
< sizeof(INDEX_HEADER))
|| (le32_to_cpu(ir->index.index_length)
& 0xff000000)
|| ((le32_to_cpu(a->value_length)
- le32_to_cpu(ir->index.index_length))
< offsetof(INDEX_ROOT,index))
|| ((le32_to_cpu(a->value_length)
- le32_to_cpu(ir->index.index_length))
< le32_to_cpu(ir->index.entries_offset))
|| (le32_to_cpu(ir->index.index_length)
> le32_to_cpu(ir->index.allocated_size))) {
|| (le32_to_cpu(ir->index.allocated_size)
< le32_to_cpu(ir->index.index_length))
|| (le32_to_cpu(a->value_length)
< (le32_to_cpu(ir->index.allocated_size)
+ offsetof(INDEX_ROOT, reserved)))) {
ntfs_log_error("Corrupt index root"
" in MFT record %lld.\n",
(long long)inum);