Skip to content

Commit 5ad414f

Browse files
Dan Carpenteraalexandrovich
authored andcommitted
fs/ntfs3: Fix a couple integer overflows on 32bit systems
On 32bit systems the "off + sizeof(struct NTFS_DE)" addition can have an integer wrapping issue. Fix it by using size_add(). Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent b432163 commit 5ad414f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/ntfs3/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ static bool index_hdr_check(const struct INDEX_HDR *hdr, u32 bytes)
618618
u32 off = le32_to_cpu(hdr->de_off);
619619

620620
if (!IS_ALIGNED(off, 8) || tot > bytes || end > tot ||
621-
off + sizeof(struct NTFS_DE) > end) {
621+
size_add(off, sizeof(struct NTFS_DE)) > end) {
622622
/* incorrect index buffer. */
623623
return false;
624624
}
@@ -736,7 +736,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
736736
if (end > total)
737737
return NULL;
738738

739-
if (off + sizeof(struct NTFS_DE) > end)
739+
if (size_add(off, sizeof(struct NTFS_DE)) > end)
740740
return NULL;
741741

742742
e = Add2Ptr(hdr, off);

0 commit comments

Comments
 (0)