]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: add an explicit talloc_stackframe() to form_junctions()
authorStefan Metzmacher <metze@samba.org>
Thu, 24 May 2018 15:40:27 +0000 (17:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jun 2018 18:52:21 +0000 (20:52 +0200)
This makes further changes simpler.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/msdfs.c

index 4e20358f5670dbad0b0c65945208f7f3ead538b9..53a4dd2dfcc9428748bcd5b0c05b8fd1f45de85a 100644 (file)
@@ -1654,13 +1654,14 @@ static int form_junctions(TALLOC_CTX *ctx,
                                struct junction_map *jucn,
                                size_t jn_remain)
 {
+       TALLOC_CTX *frame = talloc_stackframe();
        size_t cnt = 0;
        DIR *dirp = NULL;
        const char *dname = NULL;
        char *talloced = NULL;
-       const char *connect_path = lp_path(talloc_tos(), snum);
-       char *service_name = lp_servicename(talloc_tos(), snum);
-       const char *msdfs_proxy = lp_msdfs_proxy(talloc_tos(), snum);
+       const char *connect_path = lp_path(frame, snum);
+       char *service_name = lp_servicename(frame, snum);
+       const char *msdfs_proxy = lp_msdfs_proxy(frame, snum);
        connection_struct *conn;
        struct referral *ref = NULL;
        struct smb_filename *cwd_fname = NULL;
@@ -1668,10 +1669,12 @@ static int form_junctions(TALLOC_CTX *ctx,
        NTSTATUS status;
 
        if (jn_remain == 0) {
+               TALLOC_FREE(frame);
                return 0;
        }
 
        if(*connect_path == '\0') {
+               TALLOC_FREE(frame);
                return 0;
        }
 
@@ -1679,7 +1682,7 @@ static int form_junctions(TALLOC_CTX *ctx,
         * Fake up a connection struct for the VFS layer.
         */
 
-       status = create_conn_struct_cwd(ctx,
+       status = create_conn_struct_cwd(frame,
                                        server_event_context(),
                                        server_messaging_context(),
                                        &conn,
@@ -1690,6 +1693,7 @@ static int form_junctions(TALLOC_CTX *ctx,
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(3, ("create_conn_struct failed: %s\n",
                          nt_errstr(status)));
+               TALLOC_FREE(frame);
                return 0;
        }
 
@@ -1732,7 +1736,7 @@ static int form_junctions(TALLOC_CTX *ctx,
                goto out;
        }
 
-       smb_fname = synthetic_smb_fname(talloc_tos(),
+       smb_fname = synthetic_smb_fname(frame,
                                        ".",
                                        NULL,
                                        NULL,
@@ -1799,10 +1803,9 @@ out:
                SMB_VFS_CLOSEDIR(conn,dirp);
        }
 
-       TALLOC_FREE(smb_fname);
        vfs_ChDir(conn, cwd_fname);
-       TALLOC_FREE(cwd_fname);
        conn_free(conn);
+       TALLOC_FREE(frame);
        return cnt;
 }