smbd: On error exit in create_file_unixpath(), we can't call close_file() on uncomple...
authorJeremy Allison <jra@samba.org>
Wed, 16 Dec 2020 23:44:41 +0000 (15:44 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 17 Dec 2020 18:56:28 +0000 (18:56 +0000)
We can't call directly into close_file(), as that cannot deal
with regular file and directory opens where fsp->fsp_flags.is_fsa
hasn't been set to true (uncompleted opens).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 87857f350d1b30491bdee4dd4f52e533ac3af130..6ba0f5759dd471e6e0d5b86310b5b16f644868d9 100644 (file)
@@ -6091,7 +6091,13 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                         */
                        base_fsp = NULL;
                }
-               close_file(req, fsp, ERROR_CLOSE);
+               if (!fsp->fsp_flags.is_fsa) {
+                       /* Open wasn't completed. */
+                       fd_close(fsp);
+                       file_free(req, fsp);
+               } else {
+                       close_file(req, fsp, ERROR_CLOSE);
+               }
                fsp = NULL;
        }
        if (base_fsp != NULL) {