From: Ralph Boehme Date: Thu, 12 Nov 2020 14:46:57 +0000 (+0100) Subject: smbd: use openat_pathref_fsp() in copy_file() X-Git-Tag: samba-4.14.0rc1~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bdac4f81242d69fc75705614dbe69cddc7667c4;p=thirdparty%2Fsamba.git smbd: use openat_pathref_fsp() in copy_file() Ensures we have a pathref handle in the smb_fname we pass to SMB_VFS_CREATE_FILE(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 2dbe3c60b8a..ac997df2e8e 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -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 */