Skip to content

Commit 70dd48c

Browse files
fs/ntfs3: Make checks in run_unpack more clear
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent c4a8ba3 commit 70dd48c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/ntfs3/run.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
959959
* Large positive number requires to store 5 bytes
960960
* e.g.: 05 FF 7E FF FF 00 00 00
961961
*/
962-
if (size_size > 8)
962+
if (size_size > sizeof(len))
963963
return -EINVAL;
964964

965965
len = run_unpack_s64(run_buf, size_size, 0);
@@ -971,7 +971,7 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
971971

972972
if (!offset_size)
973973
lcn = SPARSE_LCN64;
974-
else if (offset_size <= 8) {
974+
else if (offset_size <= sizeof(s64)) {
975975
s64 dlcn;
976976

977977
/* Initial value of dlcn is -1 or 0. */
@@ -984,8 +984,10 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
984984
return -EINVAL;
985985
lcn = prev_lcn + dlcn;
986986
prev_lcn = lcn;
987-
} else
987+
} else {
988+
/* The size of 'dlcn' can't be > 8. */
988989
return -EINVAL;
990+
}
989991

990992
next_vcn = vcn64 + len;
991993
/* Check boundary. */

0 commit comments

Comments
 (0)