From 394ac908c19bd54e6869865ddff44e2382aedb48 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 May 2018 16:39:16 -0700 Subject: [PATCH] s3: smbd: Remove the handling of offset == -1 in real_write_file(). 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 Reviewed-by: Ralph Boehme --- source3/smbd/fileio.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 7b17889b55c..1c8bb41620c 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -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)); -- 2.34.1