Skip to content

Commit 6bb81b9

Browse files
Dan Carpenteraalexandrovich
authored andcommitted
fs/ntfs3: Prevent integer overflow in hdr_first_de()
The "de_off" and "used" variables come from the disk so they both need to check. The problem is that on 32bit systems if they're both greater than UINT_MAX - 16 then the check does work as intended because of an integer overflow. Fixes: 60ce8df ("fs/ntfs3: Fix wrong if in hdr_first_de") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 5ad414f commit 6bb81b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ntfs3/ntfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static inline struct NTFS_DE *hdr_first_de(const struct INDEX_HDR *hdr)
717717
struct NTFS_DE *e;
718718
u16 esize;
719719

720-
if (de_off >= used || de_off + sizeof(struct NTFS_DE) > used )
720+
if (de_off >= used || size_add(de_off, sizeof(struct NTFS_DE)) > used)
721721
return NULL;
722722

723723
e = Add2Ptr(hdr, de_off);

0 commit comments

Comments
 (0)