]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify filename_convert_dirfsp()
authorVolker Lendecke <vl@samba.org>
Tue, 8 Oct 2024 13:51:06 +0000 (15:51 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 12 Nov 2024 18:07:33 +0000 (18:07 +0000)
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/filename.c

index e6bc60ae217e0bfe690312126cb189844d154a18..8f7d25841d392741d8d6e40726f4da4cc4b52bea 100644 (file)
@@ -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;
        }