From: Ralph Boehme Date: Mon, 18 May 2020 12:37:18 +0000 (+0200) Subject: smbd: handling of fsp->dirfsps in close_file() X-Git-Tag: ldb-2.2.0~431 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a947b67d788a39fb37a9a00463227e2e642bc4ec;p=thirdparty%2Fsamba.git smbd: handling of fsp->dirfsps in close_file() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 307a7ff4784..05882392ce1 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1255,6 +1255,26 @@ NTSTATUS close_file(struct smb_request *req, files_struct *fsp, NTSTATUS status; struct files_struct *base_fsp = fsp->base_fsp; + if (fsp->fsp_flags.is_dirfsp) { + /* + * The typical way to get here is via file_close_[conn|user]() + * and this is taken care of below. + */ + return NT_STATUS_OK; + } + + if (fsp->dirfsp != NULL && + fsp->dirfsp != fsp->conn->cwd_fsp) + { + status = fd_close(fsp->dirfsp); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + file_free(NULL, fsp->dirfsp); + fsp->dirfsp = NULL; + } + if (fsp->fsp_flags.is_directory) { status = close_directory(req, fsp, close_type); } else if (fsp->fake_file_handle != NULL) {