Skip to content

Commit 0addfb1

Browse files
fs/ntfs3: Improved checking of attribute's name length
Added comment, added null pointer checking. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent fc49924 commit 0addfb1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

fs/ntfs3/inode.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ static struct inode *ntfs_read_mft(struct inode *inode,
137137
rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_size);
138138
asize = le32_to_cpu(attr->size);
139139

140-
if (le16_to_cpu(attr->name_off) + attr->name_len > asize)
140+
/*
141+
* Really this check was done in 'ni_enum_attr_ex' -> ... 'mi_enum_attr'.
142+
* There not critical to check this case again
143+
*/
144+
if (attr->name_len &&
145+
sizeof(short) * attr->name_len + le16_to_cpu(attr->name_off) >
146+
asize)
141147
goto out;
142148

143149
if (attr->non_res) {

0 commit comments

Comments
 (0)