From d60175230ad97a01df7862c09b392f73e9db4a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 17 May 2021 15:36:58 +0300 Subject: [PATCH] Added consistency check of MFT attributes in ntfsfix Make sure the searched attribute is fully within the MFT record and is correctly aligned. --- ntfsprogs/ntfsfix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index 48e8a782..da92fadc 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -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);