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)
committerKarolin Seeger <kseeger@samba.org>
Tue, 5 May 2015 18:53:26 +0000 (20:53 +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>
(cherry picked from commit d68383e9638254d1b6805b3d3ea3e5e897908374)

source3/modules/vfs_default.c

index 46589bf7855a98e9c4b1305da7f5347e75fff5b6..b13ad14d5ae63f6122bbdea273958d8da8d70baf 100644 (file)
@@ -1904,8 +1904,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
@@ -1919,6 +1917,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