]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Make open_file() fail early for an existing directory we are trying to...
authorJeremy Allison <jra@samba.org>
Mon, 7 Jun 2021 20:10:30 +0000 (13:10 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:29 +0000 (13:14 +0000)
Makes sure we keep the pathref fd open for the NT_FILE_IS_A_DIRECTORY case.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index ab89ee78884f9a8f4794268d468b2fe3f34ea4c8..ed180efa1e311b1cd953f8e6e95b756733f1c4e5 100644 (file)
@@ -1310,6 +1310,14 @@ static NTSTATUS open_file(files_struct *fsp,
        bool truncating = (flags & O_TRUNC);
        bool open_fd = false;
 
+       /*
+        * Catch early an attempt to open an existing
+        * directory as a file.
+        */
+       if (file_existed && S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
+               return NT_STATUS_FILE_IS_A_DIRECTORY;
+       }
+
        /* Check permissions */
 
        /*