From ab82dbc5ae43cdb661bf49627a84926163bc8998 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 1 Feb 2021 12:00:35 +0100 Subject: [PATCH] smbd: stat path before calling openat_pathref_fsp() in unlink_internals() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/reply.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index c418f39cf3b..a09e11e8493 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -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)) -- 2.47.3