smbd: use openat_pathref_fsp() in copy_file()
authorRalph Boehme <slow@samba.org>
Thu, 12 Nov 2020 14:46:57 +0000 (15:46 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:31 +0000 (09:08 +0000)
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/reply.c

index 2dbe3c60b8aa373087e4805eaeb2911c42dc37e3..ac997df2e8e745b25c693676f8a4bdf03474ceb0 100644 (file)
@@ -8501,6 +8501,14 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                goto out;
        }
 
+       status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
+               status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+       if (!NT_STATUS_IS_OK(status)) {
+               goto out;
+       }
+
        if (!target_is_directory && count) {
                new_create_disposition = FILE_OPEN;
        } else {
@@ -8545,6 +8553,17 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                ZERO_STRUCTP(&smb_fname_dst_tmp->st);
        }
 
+       status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_dst);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
+               status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+               goto out;
+       }
+       if (!NT_STATUS_IS_OK(status) &&
+           !NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND))
+       {
+               goto out;
+       }
+
        /* Open the dst file for writing. */
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */