From d7069c60f185c88260ece247c8962e500bd692d2 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Wed, 7 Oct 2015 22:44:11 +0300 Subject: [PATCH] vfs_commit: set the fd on open before calling SMB_VFS_FSTAT BUG: https://bugzilla.samba.org/show_bug.cgi?id=11547 Signed-off-by: Uri Simchoni Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Oct 8 02:56:41 CEST 2015 on sn-devel-104 (cherry picked from commit 5709dece4860f205e31309e31ec4e3e938d9f6a5) --- source3/modules/vfs_commit.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index a6bc2a4..f1e2743 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -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; -- 1.9.1