[PATCH] Fix vfs_commit in case "eof mode" is not "none"
Jeremy Allison
jra at samba.org
Wed Oct 7 21:54:11 UTC 2015
On Wed, Oct 07, 2015 at 11:06:16PM +0300, Uri Simchoni wrote:
> Stumbled upon this one when fiddling with open code of some VFS modules...
>
> Seems like an SMB_VFS_FSTAT is attempted without a file descriptor.
>
> https://bugzilla.samba.org/show_bug.cgi?id=11547
>
> Please review.
Oooh. Good catch ! Pushed.
> I also have to wonder about calling SMB_VFS_FSTAT - seems like
> SMB_VFS_NEXT_FSTAT would be the correct thing to do.
Actually, as this module doesn't implement FSTAT,
then SMB_VFS_FSTAT == SMB_VFS_NEXT_FSTAT.
> From 93652b506b56921eb2bc47238d4b398139991d28 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> 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 <uri at samba.org>
> ---
> 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
>
More information about the samba-technical
mailing list