fs/ntfs3: Improved checking of attribute's name length
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 29 Dec 2022 11:50:41 +0000 (15:50 +0400)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 27 Mar 2023 12:59:14 +0000 (16:59 +0400)
Added comment, added null pointer checking.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/inode.c

index 059f288784580548266777380cee325c26b832cb..3d2e4c1270e49af37773fc6b7d2f40054804f71d 100644 (file)
@@ -137,7 +137,13 @@ next_attr:
        rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_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;
 
        if (attr->non_res) {