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>
This commit is contained in:
Konstantin Komarov 2022-12-29 15:50:41 +04:00
parent fc4992458e
commit 0addfb1c22
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -137,7 +137,13 @@ next_attr:
rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_size); rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_size);
asize = le32_to_cpu(attr->size); asize = le32_to_cpu(attr->size);
if (le16_to_cpu(attr->name_off) + attr->name_len > asize) /*
* Really this check was done in 'ni_enum_attr_ex' -> ... 'mi_enum_attr'.
* There not critical to check this case again
*/
if (attr->name_len &&
sizeof(short) * attr->name_len + le16_to_cpu(attr->name_off) >
asize)
goto out; goto out;
if (attr->non_res) { if (attr->non_res) {