s3:smbd: let openat_pathref_fsp() allocate fsp->fsp_name directly on fsp
authorStefan Metzmacher <metze@samba.org>
Wed, 16 Dec 2020 13:50:08 +0000 (14:50 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jan 2021 11:30:38 +0000 (11:30 +0000)
Otherwise we'll always keep the current talloc_stackframe arround.

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

index 70e128a3c5c466f2bf60e5791f01bfbba7742a09..092cfcc011036ba28ce45ce9bcca6f24ed978c45 100644 (file)
@@ -445,7 +445,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                open_flags |= O_DIRECTORY;
        }
 
-       full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+       full_fname = full_path_from_dirfsp_atname(fsp,
                                                  dirfsp,
                                                  smb_fname);
        if (full_fname == NULL) {
@@ -453,12 +453,12 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                goto fail;
        }
 
-       fsp->fsp_name = talloc_move(fsp, &full_fname);
-
-       if (is_ntfs_default_stream_smb_fname(fsp->fsp_name)) {
-               fsp->fsp_name->stream_name = NULL;
+       if (is_ntfs_default_stream_smb_fname(full_fname)) {
+               full_fname->stream_name = NULL;
        }
 
+       fsp->fsp_name = full_fname;
+
        status = file_name_hash(fsp->conn,
                                smb_fname_str_dbg(fsp->fsp_name),
                                &fsp->name_hash);