]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: stat path before calling openat_pathref_fsp() in unlink_internals()
authorRalph Boehme <slow@samba.org>
Mon, 1 Feb 2021 11:00:35 +0000 (12:00 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 5 Feb 2021 06:22:35 +0000 (06:22 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/reply.c

index c418f39cf3bf61a853761dcc96da79835ca25044..a09e11e84937a46379fe547dc10a0afe32bbfed2 100644 (file)
@@ -3281,6 +3281,7 @@ NTSTATUS unlink_internals(connection_struct *conn,
        NTSTATUS status = NT_STATUS_OK;
        struct smb_filename *smb_fname_dir = NULL;
        TALLOC_CTX *ctx = talloc_tos();
+       int ret;
 
        /* Split up the directory from the filename/mask. */
        status = split_fname_dir_mask(ctx, smb_fname->base_name,
@@ -3457,6 +3458,15 @@ NTSTATUS unlink_internals(connection_struct *conn,
                                goto out;
                        }
 
+                       ret = vfs_stat(conn, f);
+                       if (ret != 0) {
+                               status = map_nt_error_from_unix(errno);
+                               TALLOC_FREE(dir_hnd);
+                               TALLOC_FREE(frame);
+                               TALLOC_FREE(talloced);
+                               goto out;
+                       }
+
                        status = openat_pathref_fsp(conn->cwd_fsp, f);
                        if (!NT_STATUS_IS_OK(status) &&
                            !NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK))