From 31b59bbf99835279a0a78858aca2f327150eb5e2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 13 Jul 2010 15:43:44 -0400 Subject: s3-dcerpc: Convert rdata from prs_struct to a simple DATA_BLOB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner --- source3/rpc_server/rpc_ncacn_np_internal.c | 19 +++------------ source3/rpc_server/srv_pipe.c | 38 +++++++++++++++--------------- source3/rpc_server/srv_pipe_hnd.c | 22 +++++------------ 3 files changed, 28 insertions(+), 51 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/rpc_ncacn_np_internal.c b/source3/rpc_server/rpc_ncacn_np_internal.c index 22e03525ff..ceda2c781c 100644 --- a/source3/rpc_server/rpc_ncacn_np_internal.c +++ b/source3/rpc_server/rpc_ncacn_np_internal.c @@ -172,11 +172,6 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, p->endian = RPC_LITTLE_ENDIAN; - /* - * Initialize the outgoing RPC data buffer with no memory. - */ - prs_init_empty(&p->out_data.rdata, p->mem_ctx, MARSHALL); - p->syntax = *syntax; DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", @@ -247,8 +242,6 @@ static NTSTATUS internal_ndr_pull(TALLOC_CTX *mem_ctx, const struct ndr_interface_call *call; struct ndr_pull *pull; enum ndr_err_code ndr_err; - DATA_BLOB blob; - bool ret; if (!ndr_syntax_id_equal(&table->syntax_id, &cli->abstract_syntax) || (opnum >= table->num_calls)) { @@ -257,12 +250,8 @@ static NTSTATUS internal_ndr_pull(TALLOC_CTX *mem_ctx, call = &table->calls[opnum]; - ret = prs_data_blob(&cli->pipes_struct->out_data.rdata, &blob, mem_ctx); - if (!ret) { - return NT_STATUS_NO_MEMORY; - } - - pull = ndr_pull_init_blob(&blob, mem_ctx); + pull = ndr_pull_init_blob(&cli->pipes_struct->out_data.rdata, + mem_ctx); if (pull == NULL) { return NT_STATUS_NO_MEMORY; } @@ -314,8 +303,6 @@ static NTSTATUS rpc_pipe_internal_dispatch(struct rpc_pipe_client *cli, return NT_STATUS_INVALID_PARAMETER; } - prs_init_empty(&cli->pipes_struct->out_data.rdata, cli->pipes_struct->mem_ctx, MARSHALL); - status = internal_ndr_push(mem_ctx, cli, table, opnum, r); if (!NT_STATUS_IS_OK(status)) { return status; @@ -331,7 +318,7 @@ static NTSTATUS rpc_pipe_internal_dispatch(struct rpc_pipe_client *cli, } prs_mem_free(&cli->pipes_struct->in_data.data); - prs_mem_free(&cli->pipes_struct->out_data.rdata); + data_blob_free(&cli->pipes_struct->out_data.rdata); return NT_STATUS_OK; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2fa598f428..b8807f17d2 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -95,7 +95,7 @@ static bool create_next_pdu_ntlmssp(pipes_struct *p) * Work out how much we can fit in a single PDU. */ - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + data_len_left = p->out_data.rdata.length - p->out_data.data_sent_length; /* * Ensure there really is data left to send. @@ -141,7 +141,7 @@ static bool create_next_pdu_ntlmssp(pipes_struct *p) * Work out if this PDU will be the last. */ if (p->out_data.data_sent_length + data_len >= - prs_offset(&p->out_data.rdata)) { + p->out_data.rdata.length) { hdr_flags |= DCERPC_PFC_FLAG_LAST; } @@ -153,7 +153,7 @@ static bool create_next_pdu_ntlmssp(pipes_struct *p) /* Set the data into the PDU. */ u.response.stub_and_verifier = - data_blob_const(prs_data_p(&p->out_data.rdata), data_len); + data_blob_const(p->out_data.rdata.data, data_len); status = dcerpc_push_ncacn_packet( prs_get_mem_context(&p->out_data.frag), @@ -331,7 +331,7 @@ static bool create_next_pdu_schannel(pipes_struct *p) * Work out how much we can fit in a single PDU. */ - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + data_len_left = p->out_data.rdata.length - p->out_data.data_sent_length; /* * Ensure there really is data left to send. @@ -378,7 +378,7 @@ static bool create_next_pdu_schannel(pipes_struct *p) * Work out if this PDU will be the last. */ if (p->out_data.data_sent_length + data_len >= - prs_offset(&p->out_data.rdata)) { + p->out_data.rdata.length) { hdr_flags |= DCERPC_PFC_FLAG_LAST; } @@ -390,7 +390,7 @@ static bool create_next_pdu_schannel(pipes_struct *p) /* Set the data into the PDU. */ u.response.stub_and_verifier = - data_blob_const(prs_data_p(&p->out_data.rdata) + + data_blob_const(p->out_data.rdata.data + p->out_data.data_sent_length, data_len); status = dcerpc_push_ncacn_packet( @@ -550,7 +550,7 @@ static bool create_next_pdu_noauth(pipes_struct *p) * Work out how much we can fit in a single PDU. */ - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + data_len_left = p->out_data.rdata.length - p->out_data.data_sent_length; /* * Ensure there really is data left to send. @@ -581,7 +581,7 @@ static bool create_next_pdu_noauth(pipes_struct *p) /* * Work out if this PDU will be the last. */ - if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { + if(p->out_data.data_sent_length + data_len >= p->out_data.rdata.length) { hdr_flags |= DCERPC_PFC_FLAG_LAST; } @@ -593,7 +593,7 @@ static bool create_next_pdu_noauth(pipes_struct *p) /* Set the data into the PDU. */ u.response.stub_and_verifier = - data_blob_const(prs_data_p(&p->out_data.rdata) + + data_blob_const(p->out_data.rdata.data + p->out_data.data_sent_length, data_len); status = dcerpc_push_ncacn_packet( @@ -831,7 +831,7 @@ static bool setup_bind_nak(pipes_struct *p, struct ncacn_packet *pkt) DATA_BLOB blob; /* Free any memory in the current return data buffer. */ - prs_mem_free(&p->out_data.rdata); + data_blob_free(&p->out_data.rdata); /* * Marshall directly into the outgoing PDU space. We @@ -892,7 +892,7 @@ bool setup_fault_pdu(pipes_struct *p, NTSTATUS fault_status) DATA_BLOB blob; /* Free any memory in the current return data buffer. */ - prs_mem_free(&p->out_data.rdata); + data_blob_free(&p->out_data.rdata); /* * Marshall directly into the outgoing PDU space. We @@ -1981,7 +1981,7 @@ bool api_pipe_request(pipes_struct *p, struct ncacn_packet *pkt) ((p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) || (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { if(!become_authenticated_pipe_user(p)) { - prs_mem_free(&p->out_data.rdata); + data_blob_free(&p->out_data.rdata); return False; } changed_user = True; @@ -2023,7 +2023,7 @@ static bool api_rpcTNP(pipes_struct *p, struct ncacn_packet *pkt, const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; - uint32 offset1, offset2; + uint32_t offset1; /* interpret the command */ DEBUG(4,("api_rpcTNP: %s op 0x%x - ", @@ -2057,7 +2057,7 @@ static bool api_rpcTNP(pipes_struct *p, struct ncacn_packet *pkt, return True; } - offset1 = prs_offset(&p->out_data.rdata); + offset1 = p->out_data.rdata.length; DEBUG(6, ("api_rpc_cmds[%d].fn == %p\n", fn_num, api_rpc_cmds[fn_num].fn)); @@ -2066,7 +2066,7 @@ static bool api_rpcTNP(pipes_struct *p, struct ncacn_packet *pkt, DEBUG(0,("api_rpcTNP: %s: %s failed.\n", get_pipe_name_from_syntax(talloc_tos(), &p->syntax), api_rpc_cmds[fn_num].name)); - prs_mem_free(&p->out_data.rdata); + data_blob_free(&p->out_data.rdata); return False; } @@ -2084,15 +2084,15 @@ static bool api_rpcTNP(pipes_struct *p, struct ncacn_packet *pkt, return True; } - offset2 = prs_offset(&p->out_data.rdata); - prs_set_offset(&p->out_data.rdata, offset1); if (DEBUGLEVEL >= 50) { fstring name; slprintf(name, sizeof(name)-1, "out_%s", get_pipe_name_from_syntax(talloc_tos(), &p->syntax)); - prs_dump(name, pkt->u.request.opnum, &p->out_data.rdata); + prs_dump_region(name, pkt->u.request.opnum, + p->out_data.rdata.data, + offset1, + p->out_data.rdata.length); } - prs_set_offset(&p->out_data.rdata, offset2); DEBUG(5,("api_rpcTNP: called %s successfully\n", get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b86a83bf07..3cd9028f44 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -45,16 +45,7 @@ static bool pipe_init_outgoing_data(pipes_struct *p) prs_mem_free(&o_data->frag); /* Free any memory in the current return data buffer. */ - prs_mem_free(&o_data->rdata); - - /* - * Initialize the outgoing RPC data buffer. - * we will use this as the raw data area for replying to rpc requests. - */ - if(!prs_init(&o_data->rdata, 128, p->mem_ctx, MARSHALL)) { - DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); - return False; - } + data_blob_free(&o_data->rdata); return True; } @@ -153,7 +144,7 @@ static bool get_pdu_size(pipes_struct *p) static void free_pipe_context(pipes_struct *p) { prs_mem_free(&p->out_data.frag); - prs_mem_free(&p->out_data.rdata); + data_blob_free(&p->out_data.rdata); prs_mem_free(&p->in_data.data); DEBUG(3, ("free_pipe_context: " @@ -840,13 +831,13 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, */ DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length " - "= %u, prs_offset(&p->out_data.rdata) = %u.\n", + "= %u, p->out_data.rdata.length = %u.\n", get_pipe_name_from_syntax(talloc_tos(), &p->syntax), (int)p->fault_state, (unsigned int)p->out_data.data_sent_length, - (unsigned int)prs_offset(&p->out_data.rdata) )); + (unsigned int)p->out_data.rdata.length)); - if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { + if (p->out_data.data_sent_length >= p->out_data.rdata.length) { /* * We have sent all possible data, return 0. */ @@ -882,8 +873,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, p->out_data.current_pdu_sent = 0; prs_mem_free(&p->out_data.frag); - if (p->out_data.data_sent_length - >= prs_offset(&p->out_data.rdata)) { + if (p->out_data.data_sent_length >= p->out_data.rdata.length) { /* * We're completely finished with both outgoing and * incoming data streams. It's safe to free all -- cgit