]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use move_smb_fname_fsp_link() in fsp_set_smb_fname()
authorRalph Boehme <slow@samba.org>
Mon, 23 Nov 2020 05:23:12 +0000 (06:23 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/files.c

index fb3934867b12aba803def5e40fb95a1a2adbda03..4fa3bf4f71686ba517ce901b57967976a2e6673a 100644 (file)
@@ -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,