rpc_server: Make make_server_pipes_struct API safer
authorVolker Lendecke <vl@samba.org>
Wed, 20 Mar 2019 12:50:03 +0000 (13:50 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 22 Mar 2019 18:02:16 +0000 (18:02 +0000)
Make it clear that we talloc_steal by NULLing out the caller's
session_info

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpc_server/rpc_ncacn_np.c
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h

index 5ee98a1..2b48336 100644 (file)
@@ -164,7 +164,7 @@ NTSTATUS make_internal_rpc_pipe_socketpair(
                                      NCACN_NP,
                                      npc->remote_client_addr,
                                      npc->local_server_addr,
-                                     npc->session_info,
+                                     &npc->session_info,
                                      &npc->p,
                                      &error);
        if (rc == -1) {
index 050f36d..2f6ad6e 100644 (file)
@@ -42,10 +42,11 @@ int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
                             enum dcerpc_transport_t transport,
                             const struct tsocket_address *remote_address,
                             const struct tsocket_address *local_address,
-                            struct auth_session_info *session_info,
+                            struct auth_session_info **psession_info,
                             struct pipes_struct **_p,
                             int *perrno)
 {
+       struct auth_session_info *session_info = *psession_info;
        struct pipes_struct *p;
        int ret;
 
@@ -67,7 +68,7 @@ int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
        }
 
        /* Don't call create_local_token(), we already have the full details here */
-       p->session_info = talloc_steal(p, session_info);
+       p->session_info = talloc_move(p, psession_info);
 
        *_p = p;
        return 0;
@@ -380,7 +381,7 @@ static void named_pipe_accept_done(struct tevent_req *subreq)
                                       npc->pipe_name, NCACN_NP,
                                       npc->remote_client_addr,
                                       npc->local_server_addr,
-                                      npc->session_info,
+                                      &npc->session_info,
                                       &npc->p, &error);
        if (ret != 0) {
                DEBUG(2, ("Failed to create pipes_struct! (%s)\n",
@@ -1127,7 +1128,7 @@ void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
                                      ncacn_conn->transport,
                                      ncacn_conn->remote_client_addr,
                                      ncacn_conn->local_server_addr,
-                                     ncacn_conn->session_info,
+                                     &ncacn_conn->session_info,
                                      &ncacn_conn->p,
                                      &sys_errno);
        if (rc < 0) {
index fd8c652..3140e96 100644 (file)
@@ -71,7 +71,7 @@ int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
                             enum dcerpc_transport_t transport,
                             const struct tsocket_address *remote_address,
                             const struct tsocket_address *local_address,
-                            struct auth_session_info *session_info,
+                            struct auth_session_info **session_info,
                             struct pipes_struct **_p,
                             int *perrno);