s3: smbd: Remove the handling of offset == -1 in real_write_file().
authorJeremy Allison <jra@samba.org>
Wed, 2 May 2018 23:39:16 +0000 (16:39 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 4 May 2018 20:34:25 +0000 (22:34 +0200)
All SMB1/2/3 offsets over the wire are absolute.

The only caller with offset == -1 is on a print-spool file
in reply_printwrite(), and write_file() redirects this
to print_spool_write(), which correctly handles the -1.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/fileio.c

index 7b17889..1c8bb41 100644 (file)
@@ -115,18 +115,14 @@ static ssize_t real_write_file(struct smb_request *req,
 {
        ssize_t ret;
 
-        if (pos == -1) {
-                ret = vfs_write_data(req, fsp, data, n);
-        } else {
-               fsp->fh->pos = pos;
-               if (pos && lp_strict_allocate(SNUM(fsp->conn) &&
-                               !fsp->is_sparse)) {
-                       if (vfs_fill_sparse(fsp, pos) == -1) {
-                               return -1;
-                       }
+       fsp->fh->pos = pos;
+       if (pos && lp_strict_allocate(SNUM(fsp->conn) &&
+                       !fsp->is_sparse)) {
+               if (vfs_fill_sparse(fsp, pos) == -1) {
+                       return -1;
                }
-                ret = vfs_pwrite_data(req, fsp, data, n, pos);
        }
+       ret = vfs_pwrite_data(req, fsp, data, n, pos);
 
        DEBUG(10,("real_write_file (%s): pos = %.0f, size = %lu, returned %ld\n",
                  fsp_str_dbg(fsp), (double)pos, (unsigned long)n, (long)ret));