Added consistency check of MFT attributes in ntfsfix

Make sure the searched attribute is fully within the MFT record and is
correctly aligned.
edge.strict_endians^2
Jean-Pierre André 2021-05-17 15:36:58 +03:00 committed by Erik Larsson
parent 5bdfac9704
commit d60175230a
1 changed files with 3 additions and 1 deletions

View File

@ -784,7 +784,9 @@ static ATTR_RECORD *find_unnamed_attr(MFT_RECORD *mrec, ATTR_TYPES type)
/* fetch the requested attribute */
offset = le16_to_cpu(mrec->attrs_offset);
a = (ATTR_RECORD*)((char*)mrec + offset);
while ((offset < le32_to_cpu(mrec->bytes_in_use))
while (((offset + le32_to_cpu(a->length))
< le32_to_cpu(mrec->bytes_in_use))
&& !(le32_to_cpu(a->length) & 7)
&& (a->type != AT_END)
&& ((a->type != type) || a->name_length)) {
offset += le32_to_cpu(a->length);