]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: add vfs_valid_allocation_range() as a copy of vfs_valid_pwrite_range()
authorRalph Boehme <slow@samba.org>
Fri, 29 Nov 2024 12:00:30 +0000 (13:00 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 7 Jan 2025 22:04:33 +0000 (22:04 +0000)
Not a copy of the whole code obviously, a copy of behaviour. A subsequent commit
will further change vfs_valid_pwrite_range().

Existing callers of vfs_valid_pwrite_range() that are not calling it in the
write-IO codepath, but when dealing with allocation and size, are converted to
use vfs_valid_allocation_range().

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c
source3/smbd/proto.h
source3/smbd/vfs.c

index f4032656e1f5fc1745209e9bfc454aaaaa35bf17..a48a4de40a6653fd3ea250288f2c10d6c3937adc 100644 (file)
@@ -2894,7 +2894,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
        SMB_STRUCT_STAT *pst;
        bool ok;
 
-       ok = vfs_valid_pwrite_range(len, 0);
+       ok = vfs_valid_allocation_range(len, 0);
        if (!ok) {
                errno = EINVAL;
                return -1;
index e7de9df4683774c330eb333c10c3f09ed5d74b20..e61b137ea1316ca5bccd321fe890eaea04ba500e 100644 (file)
@@ -1166,6 +1166,7 @@ bool smbd_vfs_init(connection_struct *conn);
 NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname);
 bool vfs_valid_pread_range(off_t offset, size_t length);
 bool vfs_valid_pwrite_range(off_t offset, size_t length);
+bool vfs_valid_allocation_range(off_t offset, size_t length);
 ssize_t vfs_pwrite_data(struct smb_request *req,
                        files_struct *fsp,
                        const char *buffer,
index 462f57f854eb19c071ece0553b91c68cbb09d6c0..512fa361a15775a39cbb844f79a3b9beb99c3ae8 100644 (file)
@@ -423,7 +423,7 @@ bool vfs_valid_pread_range(off_t offset, size_t length)
        return sys_valid_io_range(offset, length);
 }
 
-bool vfs_valid_pwrite_range(off_t offset, size_t length)
+bool vfs_valid_allocation_range(off_t offset, size_t length)
 {
        /*
         * See MAXFILESIZE in [MS-FSA] 2.1.5.3 Server Requests a Write
@@ -449,6 +449,11 @@ bool vfs_valid_pwrite_range(off_t offset, size_t length)
        return true;
 }
 
+bool vfs_valid_pwrite_range(off_t offset, size_t length)
+{
+       return vfs_valid_allocation_range(offset, length);
+}
+
 ssize_t vfs_pwrite_data(struct smb_request *req,
                        files_struct *fsp,
                        const char *buffer,
@@ -549,7 +554,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
        DEBUG(10,("vfs_allocate_file_space: file %s, len %.0f\n",
                  fsp_str_dbg(fsp), (double)len));
 
-       ok = vfs_valid_pwrite_range((off_t)len, 0);
+       ok = vfs_valid_allocation_range((off_t)len, 0);
        if (!ok) {
                DEBUG(0,("vfs_allocate_file_space: %s negative/invalid len "
                         "requested.\n", fsp_str_dbg(fsp)));
@@ -638,7 +643,7 @@ int vfs_set_filelen(files_struct *fsp, off_t len)
        int ret;
        bool ok;
 
-       ok = vfs_valid_pwrite_range(len, 0);
+       ok = vfs_valid_allocation_range(len, 0);
        if (!ok) {
                errno = EINVAL;
                return -1;
@@ -679,7 +684,7 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len)
        size_t total = 0;
        bool ok;
 
-       ok = vfs_valid_pwrite_range(offset, len);
+       ok = vfs_valid_allocation_range(offset, len);
        if (!ok) {
                errno = EINVAL;
                return -1;
@@ -726,7 +731,7 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
        size_t num_to_write;
        bool ok;
 
-       ok = vfs_valid_pwrite_range(len, 0);
+       ok = vfs_valid_allocation_range(len, 0);
        if (!ok) {
                errno = EINVAL;
                return -1;