]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: handling of fsp->dirfsps in close_file()
authorRalph Boehme <slow@samba.org>
Mon, 18 May 2020 12:37:18 +0000 (14:37 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 21 May 2020 05:23:30 +0000 (05:23 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/close.c

index 307a7ff4784406a704547eb9639f70b98d8d50d9..05882392ce1cf2c8e9156bd36e1f2a198bc14f3c 100644 (file)
@@ -1255,6 +1255,26 @@ NTSTATUS close_file(struct smb_request *req, files_struct *fsp,
        NTSTATUS status;
        struct files_struct *base_fsp = fsp->base_fsp;
 
+       if (fsp->fsp_flags.is_dirfsp) {
+               /*
+                * The typical way to get here is via file_close_[conn|user]()
+                * and this is taken care of below.
+                */
+               return NT_STATUS_OK;
+       }
+
+       if (fsp->dirfsp != NULL &&
+           fsp->dirfsp != fsp->conn->cwd_fsp)
+       {
+               status = fd_close(fsp->dirfsp);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+
+               file_free(NULL, fsp->dirfsp);
+               fsp->dirfsp = NULL;
+       }
+
        if (fsp->fsp_flags.is_directory) {
                status = close_directory(req, fsp, close_type);
        } else if (fsp->fake_file_handle != NULL) {