From: Ralph Boehme Date: Mon, 23 Nov 2020 05:23:12 +0000 (+0100) Subject: smbd: use move_smb_fname_fsp_link() in fsp_set_smb_fname() X-Git-Tag: samba-4.14.0rc1~366 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b2685e28d2ab6b7b68db2bd1f615a848663d5eb5;p=thirdparty%2Fsamba.git 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 --- 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,