S3: smbd: Finish plumbing struct smb_filename * through the check_name() stack.
[metze/samba/wip.git] / source3 / smbd / open.c
index e8464ed83b2bba0e7b030bbfaf0cb48b6223f114..0eedf963f31ab54b537e75ac25425c64bfc8ffe2 100644 (file)
@@ -570,13 +570,6 @@ static int non_widelink_open(struct connection_struct *conn,
                goto out;
        }
 
-       /* Ensure the relative path is below the share. */
-       status = check_reduced_name(conn, parent_dir, final_component);
-       if (!NT_STATUS_IS_OK(status)) {
-               saved_errno = map_errno_from_nt_status(status);
-               goto out;
-       }
-
        smb_fname_rel = synthetic_smb_fname(talloc_tos(),
                                final_component,
                                smb_fname->stream_name,
@@ -587,6 +580,13 @@ static int non_widelink_open(struct connection_struct *conn,
                goto out;
        }
 
+       /* Ensure the relative path is below the share. */
+       status = check_reduced_name(conn, &parent_dir_fname, smb_fname_rel);
+       if (!NT_STATUS_IS_OK(status)) {
+               saved_errno = map_errno_from_nt_status(status);
+               goto out;
+       }
+
        flags |= O_NOFOLLOW;
 
        {