From b2685e28d2ab6b7b68db2bd1f615a848663d5eb5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 23 Nov 2020 06:23:12 +0100 Subject: [PATCH] smbd: use move_smb_fname_fsp_link() in fsp_set_smb_fname() This ensures that fsp->fsp_name->fsp is again set to the fsp and also preserves the link fsp->fsp_name->fsp_link. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/files.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index fb3934867b1..4fa3bf4f716 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -1196,13 +1196,21 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp, const struct smb_filename *smb_fname_in) { struct smb_filename *smb_fname_new; + NTSTATUS status; smb_fname_new = cp_smb_filename(fsp, smb_fname_in); if (smb_fname_new == NULL) { return NT_STATUS_NO_MEMORY; } - TALLOC_FREE(fsp->fsp_name); + if (fsp->fsp_name != NULL) { + status = move_smb_fname_fsp_link(smb_fname_new, fsp->fsp_name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + TALLOC_FREE(fsp->fsp_name); + } + fsp->fsp_name = smb_fname_new; return file_name_hash(fsp->conn, -- 2.47.3