Skip to content

Commit 519f38d

Browse files
fs/ntfs3: Fix attr_insert_range at end of file
If the offset is equal to or greater than the end of file, an error is returned. For such operations (i.e., inserting a hole at the end of file), ftruncate(2) should be used. Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 0f9579d commit 519f38d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/ntfs3/attrib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,8 +2373,13 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
23732373
mask = (sbi->cluster_size << attr_b->nres.c_unit) - 1;
23742374
}
23752375

2376-
if (vbo > data_size) {
2377-
/* Insert range after the file size is not allowed. */
2376+
if (vbo >= data_size) {
2377+
/*
2378+
* Insert range after the file size is not allowed.
2379+
* If the offset is equal to or greater than the end of
2380+
* file, an error is returned. For such operations (i.e., inserting
2381+
* a hole at the end of file), ftruncate(2) should be used.
2382+
*/
23782383
return -EINVAL;
23792384
}
23802385

0 commit comments

Comments
 (0)