From: Ralph Boehme Date: Wed, 15 Jul 2020 10:04:10 +0000 (+0200) Subject: smbd: use helper variable for fd in fd_open() X-Git-Tag: talloc-2.3.2~1066 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c2c749157aac80317e9de34cf99e779c0af87fe;p=thirdparty%2Fsamba.git smbd: use helper variable for fd in fd_open() No change in behaviour. Fwiw, no need to set fsp->fh->fd to -1 in the error case, as that is initialized to -1 in fsp_new(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 545c19b4d6c..9430b38b0ea 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -779,6 +779,7 @@ NTSTATUS fd_open(files_struct *fsp, struct connection_struct *conn = fsp->conn; struct smb_filename *smb_fname = fsp->fsp_name; NTSTATUS status = NT_STATUS_OK; + int fd; /* * Never follow symlinks on a POSIX client. The @@ -793,12 +794,8 @@ NTSTATUS fd_open(files_struct *fsp, * Only follow symlinks within a share * definition. */ - fsp->fh->fd = non_widelink_open(fsp, - smb_fname, - flags, - mode, - 0); - if (fsp->fh->fd == -1) { + fd = non_widelink_open(fsp, smb_fname, flags, mode, 0); + if (fd == -1) { int posix_errno = link_errno_convert(errno); status = map_nt_error_from_unix(posix_errno); if (errno == EMFILE) { @@ -815,12 +812,14 @@ NTSTATUS fd_open(files_struct *fsp, DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", smb_fname_str_dbg(smb_fname), flags, (int)mode, - fsp->fh->fd, strerror(errno)); + fd, strerror(errno)); return status; } + fsp->fh->fd = fd; + DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d\n", - smb_fname_str_dbg(smb_fname), flags, (int)mode, fsp->fh->fd); + smb_fname_str_dbg(smb_fname), flags, (int)mode, fd); return status; }