]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify filename_convert_dirfsp_nosymlink()
authorVolker Lendecke <vl@samba.org>
Fri, 11 Oct 2024 10:46:53 +0000 (12:46 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 12 Nov 2024 18:07:33 +0000 (18:07 +0000)
Looks more complex, but this avoids calling openat_pathref_fsp, which
eventually calls into non_widelink_open(). We need to open the pretty paranoid
SMB_ASSERT in openat_pathref_fsp_lcomp() a little bit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/filename.c
source3/smbd/files.c

index d5804e2e15a8b6e81e0801c40ec7efa5702d811a..89a5fe4f33842aed2c25643702bd1077666c7d3d 100644 (file)
@@ -752,14 +752,19 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
        }
 
        if (dirname[0] == '\0') {
-               status = synthetic_pathref(mem_ctx,
-                                          basedir,
-                                          ".",
-                                          NULL,
-                                          NULL,
-                                          0,
-                                          posix ? SMB_FILENAME_POSIX_PATH : 0,
-                                          &smb_dirname);
+               smb_dirname = synthetic_smb_fname(
+                       mem_ctx,
+                       ".",
+                       NULL,
+                       NULL,
+                       0,
+                       posix ? SMB_FILENAME_POSIX_PATH : 0);
+               if (smb_dirname == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               status = openat_pathref_fsp_lcomp(basedir,
+                                                 smb_dirname,
+                                                 UCF_POSIX_PATHNAMES);
        } else {
                status = normalize_filename_case(conn, dirname, ucf_flags);
                if (!NT_STATUS_IS_OK(status)) {
index 2100db5eaee641f45935f506e64000eb2fb38bdb..a8ccf4895287c2780db899012c868a6b6fdaa640 100644 (file)
@@ -1487,7 +1487,8 @@ NTSTATUS openat_pathref_fsp_lcomp(struct files_struct *dirfsp,
         */
 
        SMB_ASSERT((smb_fname_rel->fsp == NULL) &&
-                  (dirfsp != dirfsp->conn->cwd_fsp) &&
+                  ((dirfsp != dirfsp->conn->cwd_fsp) ||
+                   ISDOT(smb_fname_rel->base_name)) &&
                   (strchr_m(smb_fname_rel->base_name, '/') == NULL) &&
                   !is_named_stream(smb_fname_rel));