From: Ralph Boehme Date: Wed, 22 Apr 2020 13:13:04 +0000 (+0200) Subject: smbd: let unix_convert() fail early if initial stat fails with EACCES X-Git-Tag: ldb-2.2.0~890 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd90ca6f00b329e23100e8305fa461d452cf4651;p=thirdparty%2Fsamba.git 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 --- 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.