Move initialization of the reply prs_struct to rpc_api_pipe
authorVolker Lendecke <vl@samba.org>
Sat, 17 Jan 2009 11:18:29 +0000 (12:18 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 18 Jan 2009 14:40:44 +0000 (15:40 +0100)
source3/include/proto.h
source3/include/rpc_client.h
source3/librpc/rpc/dcerpc.c
source3/rpc_client/cli_pipe.c
source3/rpc_client/ndr.c

index d644b09a6acaed5965c14ecbceccf8ea60213a6b..9210a5cfe23e2e2d59f16a80c4b9717185253a41 100644 (file)
@@ -5197,7 +5197,7 @@ NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
 
 /* The following definitions come from rpc_client/cli_pipe.c  */
 
-NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
+NTSTATUS rpc_api_pipe_req(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
                        uint8 op_num,
                        prs_struct *in_data,
                        prs_struct *out_data);
index 684044b87190a5ca4adffde39aa8e26cb12a704e..61b861c3b4e7ebf0896d518174b2faf112c8a1e0 100644 (file)
@@ -49,9 +49,8 @@
        if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
                return WERR_NOMEM;\
        }\
-       prs_init_empty( &r_ps, ctx, UNMARSHALL );\
        if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
-               NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
+               NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(ctx, pcli, opnum, &q_ps, &r_ps); \
                if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
                        prs_mem_free( &q_ps );\
                        prs_mem_free( &r_ps );\
index 69bfc6f329a3e91d25f31c386c90e4139125618c..21a2004422c2c85bdbf42b4d2f9e7d824f01bdca 100644 (file)
@@ -84,7 +84,8 @@ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req)
 
        prs_init_empty( &r_ps, req, UNMARSHALL );
 
-       status = rpc_api_pipe_req(req->pipe->rpc_cli, req->opnum, &req->q_ps, &r_ps); 
+       status = rpc_api_pipe_req(req, req->pipe->rpc_cli, req->opnum,
+                                 &req->q_ps, &r_ps);
 
        prs_mem_free( &req->q_ps );
 
index d6f18846b1d8954219de69a0c266d049add7578b..b93f6ed844d6885c87f90cbd1e0fad0f1e2cb0e1 100644 (file)
@@ -1265,7 +1265,7 @@ static NTSTATUS cli_api_pipe(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
 
  ****************************************************************************/
 
-static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
+static NTSTATUS rpc_api_pipe(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
                        prs_struct *data, /* Outgoing pdu fragment, already formatted for send. */
                        prs_struct *rbuf, /* Incoming reply - return as an NDR stream. */
                        uint8 expected_pkt_type)
@@ -1284,7 +1284,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
        }
 
        /* Set up the current pdu parse struct. */
-       prs_init_empty(&current_pdu, prs_get_mem_context(rbuf), UNMARSHALL);
+       prs_init_empty(&current_pdu, talloc_tos(), UNMARSHALL);
 
        DEBUG(5,("rpc_api_pipe: %s\n", rpccli_pipe_txt(debug_ctx(), cli)));
 
@@ -1316,9 +1316,8 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
        }
        prs_give_memory(&current_pdu, (char *)rdata_copy, rdata_len, true);
 
-       /* Ensure we can mess with the return prs_struct. */
-       SMB_ASSERT(UNMARSHALLING(rbuf));
-       SMB_ASSERT(prs_data_size(rbuf) == 0);
+       /* Initialize the incoming PDU */
+       prs_init_empty(rbuf, mem_ctx, UNMARSHALL);
 
        /* Make rbuf dynamic with no memory. */
        prs_give_memory(rbuf, 0, 0, True);
@@ -1952,7 +1951,7 @@ static uint32 calculate_data_len_tosend(struct rpc_pipe_client *cli,
  and deals with signing/sealing details.
  ********************************************************************/
 
-NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
+NTSTATUS rpc_api_pipe_req(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
                        uint8 op_num,
                        prs_struct *in_data,
                        prs_struct *out_data)
@@ -2055,7 +2054,8 @@ NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
                /* Actually send the packet. */
                if (flags & RPC_FLG_LAST) {
                        /* Last packet - send the data, get the reply and return. */
-                       ret = rpc_api_pipe(cli, &outgoing_pdu, out_data, RPC_RESPONSE);
+                       ret = rpc_api_pipe(mem_ctx, cli, &outgoing_pdu,
+                                          out_data, RPC_RESPONSE);
                        prs_mem_free(&outgoing_pdu);
 
                        if ((DEBUGLEVEL >= 50)
@@ -2481,9 +2481,9 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
 
        /* Initialize the returning data struct. */
        prs_mem_free(rbuf);
-       prs_init_empty(rbuf, talloc_tos(), UNMARSHALL);
 
-       nt_status = rpc_api_pipe(cli, &rpc_out, rbuf, RPC_ALTCONTRESP);
+       nt_status = rpc_api_pipe(talloc_tos(), cli, &rpc_out, rbuf,
+                                RPC_ALTCONTRESP);
        prs_mem_free(&rpc_out);
        if (!NT_STATUS_IS_OK(nt_status)) {
                return nt_status;
@@ -2559,11 +2559,8 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
                return status;
        }
 
-       /* Initialize the incoming data struct. */
-       prs_init_empty(&rbuf, talloc_tos(), UNMARSHALL);
-
        /* send data on \PIPE\.  receive a response */
-       status = rpc_api_pipe(cli, &rpc_out, &rbuf, RPC_BINDACK);
+       status = rpc_api_pipe(talloc_tos(), cli, &rpc_out, &rbuf, RPC_BINDACK);
        prs_mem_free(&rpc_out);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
index 9ada47a3f5d901aeecbe456dd82a990e4ee0b771..9c3205eca3ec567803f77998c8ffa68e1caf1586 100644 (file)
@@ -59,9 +59,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
 
        talloc_free(push);
 
-       prs_init_empty( &r_ps, mem_ctx, UNMARSHALL );
-
-       status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps); 
+       status = rpc_api_pipe_req(mem_ctx, cli, opnum, &q_ps, &r_ps);
 
        prs_mem_free( &q_ps );