summaryrefslogtreecommitdiff
path: root/fs/ntfs3
diff options
context:
space:
mode:
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2024-05-30 10:44:17 +0300
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2024-06-26 15:48:50 +0300
commit519f38de57cd0c5e0043795b5fb0686c97311f6d (patch)
tree0de8262bb5b4c012b848beba99cf1bf2d2e48816 /fs/ntfs3
parent0f9579d9e0331b6255132ac06bdf2c0a01cceb90 (diff)
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 <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r--fs/ntfs3/attrib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 0d13da5523b1..68d1c61fe3b5 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -2373,8 +2373,13 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
mask = (sbi->cluster_size << attr_b->nres.c_unit) - 1;
}
- if (vbo > data_size) {
- /* Insert range after the file size is not allowed. */
+ if (vbo >= data_size) {
+ /*
+ * Insert range after the file size is not allowed.
+ * 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.
+ */
return -EINVAL;
}