smbd: stat path before calling openat_pathref_fsp() in open_pathref_base_fsp()
authorRalph Boehme <slow@samba.org>
Mon, 1 Feb 2021 11:04:01 +0000 (12:04 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 10 Jun 2021 09:31:12 +0000 (09:31 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14730

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit c31fe2f9e7d65409229b7ad73418793ab34d359d)

source3/smbd/files.c

index d9fd2b8ea86c438a7bf93f8509f1cbb4b604ffe4..02442a962ed69cc997504947dd1ac76f0c22309c 100644 (file)
@@ -395,6 +395,7 @@ static NTSTATUS open_pathref_base_fsp(const struct files_struct *dirfsp,
 {
        struct smb_filename *smb_fname_base = NULL;
        NTSTATUS status;
+       int ret;
 
        smb_fname_base = synthetic_smb_fname(talloc_tos(),
                                             fsp->fsp_name->base_name,
@@ -406,6 +407,11 @@ static NTSTATUS open_pathref_base_fsp(const struct files_struct *dirfsp,
                return NT_STATUS_NO_MEMORY;
        }
 
+       ret = vfs_stat(fsp->conn, smb_fname_base);
+       if (ret != 0) {
+               return map_nt_error_from_unix(errno);
+       }
+
        status = openat_pathref_fsp(dirfsp, smb_fname_base);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(smb_fname_base);