Skip to content

Commit 60ce8df

Browse files
fs/ntfs3: Fix wrong if in hdr_first_de
We need to check used bytes instead of total. Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 97a6815 commit 60ce8df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ntfs3/ntfs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,13 @@ static inline struct NTFS_DE *hdr_first_de(const struct INDEX_HDR *hdr)
714714
{
715715
u32 de_off = le32_to_cpu(hdr->de_off);
716716
u32 used = le32_to_cpu(hdr->used);
717-
struct NTFS_DE *e = Add2Ptr(hdr, de_off);
717+
struct NTFS_DE *e;
718718
u16 esize;
719719

720-
if (de_off >= used || de_off >= le32_to_cpu(hdr->total))
720+
if (de_off >= used || de_off + sizeof(struct NTFS_DE) > used )
721721
return NULL;
722722

723+
e = Add2Ptr(hdr, de_off);
723724
esize = le16_to_cpu(e->size);
724725
if (esize < sizeof(struct NTFS_DE) || de_off + esize > used)
725726
return NULL;

0 commit comments

Comments
 (0)