From bd90ca6f00b329e23100e8305fa461d452cf4651 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 22 Apr 2020 15:13:04 +0200 Subject: [PATCH] smbd: let unix_convert() fail early if initial stat fails with EACCES Doing directory scans on the path components is not going to change this, so give up early. No change in behaviour, as we would just fail later in get_real_filename() otherwise. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Apr 22 21:08:39 UTC 2020 on sn-devel-184 --- source3/smbd/filename.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 9faff9da45a..8030e504317 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -700,6 +700,18 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, /* Stat failed - ensure we don't use it. */ SET_STAT_INVALID(smb_fname->st); + if (errno == EACCES) { + /* + * Early exit on access denied. Walking + * the path won't fix that. + */ + DBG_DEBUG("stat [%s]: %s\n", + smb_fname_str_dbg(smb_fname), + strerror(errno)); + status = NT_STATUS_ACCESS_DENIED; + goto fail; + } + if (errno == ENOENT) { /* Optimization when creating a new file - only the last component doesn't exist. -- 2.47.3