s3: smbd: Incorrect file size returned in the response of "FILE_SUPERSEDE Create"
authorJeremy Allison <jra@samba.org>
Tue, 28 Apr 2015 21:22:42 +0000 (14:22 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 30 Apr 2015 17:35:10 +0000 (19:35 +0200)
https://bugzilla.samba.org/show_bug.cgi?id=11240

Signed-off-by: Kenny Dinh <kdinh@peaxy.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <rb@sernet.de>
source3/modules/vfs_default.c

index dbcd6016af7fc32f8f7b20c6105672034af43b25..7d2a0e5cd28768cd7ca0a5906720eb1897c3c25b 100644 (file)
@@ -1940,8 +1940,6 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
           ftruncate extend but ext2 can. */
 
        result = ftruncate(fsp->fh->fd, len);
-       if (result == 0)
-               goto done;
 
        /* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
           extend a file with ftruncate. Provide alternate implementation
@@ -1955,6 +1953,12 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
        }
+
+       /* We need to update the files_struct after successful ftruncate */
+       if (result == 0) {
+               goto done;
+       }
+
        pst = &fsp->fsp_name->st;
 
 #ifdef S_ISFIFO