From: Ralph Boehme Date: Mon, 19 Oct 2020 08:19:28 +0000 (+0200) Subject: smbd: simplify setting and resetting fsp->fsp_name in non_widelink_open() X-Git-Tag: samba-4.14.0rc1~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65c4f6158799374bd125647cd3216ed8fe6523ff;p=thirdparty%2Fsamba.git smbd: simplify setting and resetting fsp->fsp_name in non_widelink_open() Instead of setting and resetting the name to the relative name every time we call into the VFS, just set it once and reset it at the end and when recursing via process_symlink_open(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index b77f29272fb..3dff25ccf8b 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -720,7 +720,6 @@ static int non_widelink_open(const struct files_struct *dirfsp, mode); fsp_set_fd(fsp, fd); - fsp->fsp_name = orig_fsp_name; if (fd != -1 && !is_ntfs_stream_smb_fname(fsp->fsp_name) && @@ -738,24 +737,16 @@ static int non_widelink_open(const struct files_struct *dirfsp, */ int ret; - fsp->fsp_name = smb_fname_rel; - ret = SMB_VFS_FSTAT(fsp, &orig_fsp_name->st); - - fsp->fsp_name = orig_fsp_name; - if (ret != 0) { goto out; } if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) { - fsp->fsp_name = smb_fname_rel; - ret = SMB_VFS_CLOSE(fsp); SMB_ASSERT(ret == 0); fsp_set_fd(fsp, -1); - fsp->fsp_name = orig_fsp_name; fd = -1; errno = ELOOP; } @@ -783,6 +774,9 @@ static int non_widelink_open(const struct files_struct *dirfsp, /* Explicitly no symlinks. */ goto out; } + + fsp->fsp_name = orig_fsp_name; + /* * We may have a symlink. Follow in userspace * to ensure it's under the share definition. @@ -810,7 +804,7 @@ static int non_widelink_open(const struct files_struct *dirfsp, } out: - + fsp->fsp_name = orig_fsp_name; TALLOC_FREE(parent_dir_fname); if (oldwd_fname != NULL) {