vfs_commit: set the fd on open before calling SMB_VFS_FSTAT
authorUri Simchoni <uri@samba.org>
Wed, 7 Oct 2015 19:44:11 +0000 (22:44 +0300)
committerJeremy Allison <jra@samba.org>
Thu, 8 Oct 2015 00:56:41 +0000 (02:56 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11547

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct  8 02:56:41 CEST 2015 on sn-devel-104

source3/modules/vfs_commit.c

index a6bc2a4a65621eca06284745bd4231e072aca6e4..f1e2743b036fe045957762d598e4705e05622c05 100644 (file)
@@ -230,7 +230,16 @@ static int commit_open(
         /* EOF commit modes require us to know the initial file size. */
         if (c && (c->on_eof != EOF_NONE)) {
                 SMB_STRUCT_STAT st;
-                if (SMB_VFS_FSTAT(fsp, &st) == -1) {
+               /*
+                * Setting the fd of the FSP is a hack
+                * but also practiced elsewhere -
+                * needed for calling the VFS.
+                */
+               fsp->fh->fd = fd;
+               if (SMB_VFS_FSTAT(fsp, &st) == -1) {
+                       int saved_errno = errno;
+                       SMB_VFS_CLOSE(fsp);
+                       errno = saved_errno;
                         return -1;
                 }
                c->eof = st.st_ex_size;