From: Volker Lendecke Date: Tue, 8 Oct 2024 13:51:06 +0000 (+0200) Subject: smbd: Simplify filename_convert_dirfsp() X-Git-Tag: tdb-1.4.13~530 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd30c9c128c203c3ed4b123b651862a9953f6cf2;p=thirdparty%2Fsamba.git smbd: Simplify filename_convert_dirfsp() If we do the S_ISLNK check in the lower level, the if-condition is simpler and we get the close_file_free() call for free. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index e6bc60ae217..8f7d25841d3 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1033,6 +1033,13 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( } done: + if (S_ISLNK(smb_fname->st.st_ex_mode) && + !(ucf_flags & UCF_LCOMP_LNK_OK)) { + status = NT_STATUS_STOPPED_ON_SYMLINK; + *_symlink_err = symlink_err; + goto fail; + } + *_dirfsp = smb_dirname->fsp; *_smb_fname = smb_fname; *_symlink_err = symlink_err; @@ -1090,18 +1097,6 @@ next: _smb_fname, &symlink_err); - if (NT_STATUS_IS_OK(status) && S_ISLNK((*_smb_fname)->st.st_ex_mode)) { - /* - * lcomp is a symlink - */ - if (ucf_flags & UCF_LCOMP_LNK_OK) { - TALLOC_FREE(symlink_err); - return NT_STATUS_OK; - } - close_file_free(NULL, _dirfsp, ERROR_CLOSE); - status = NT_STATUS_STOPPED_ON_SYMLINK; - } - if (!NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { return status; }