]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: move S_ISDIR check up a bit in openat_pathref_fsp()
authorRalph Boehme <slow@samba.org>
Mon, 11 Jan 2021 08:57:26 +0000 (09:57 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 11 Jan 2021 20:25:32 +0000 (20:25 +0000)
This relies on the caller having stat()ed smb_fname instead of relying on
fd_openat() fstat()ing fsp->fsp_name. Otherwise no change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/files.c

index 57fd67ab4262df929b9a65925b9a11c3f7409d06..dff6780259b28e39bcc20ec8fd3e0aaefc6cd9df 100644 (file)
@@ -435,6 +435,9 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
        ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
        fsp->fsp_flags.is_pathref = true;
+       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+               fsp->fsp_flags.is_directory = true;
+       }
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
                                                  dirfsp,
@@ -519,9 +522,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
        }
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
-       if (S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
-               fsp->fsp_flags.is_directory = true;
-       }
 
        fsp->fsp_name->fsp = fsp;
        smb_fname->fsp = fsp;