summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-07-13 15:43:44 -0400
committerGünther Deschner <gd@samba.org>2010-07-16 01:51:16 +0200
commit31b59bbf99835279a0a78858aca2f327150eb5e2 (patch)
tree7524b7fcca9218767737c10eba864b9579f4a43a /source3
parent8246214e7ef5374acc0a1f97f4f1203374fba7f8 (diff)
downloadsamba-31b59bbf99835279a0a78858aca2f327150eb5e2.tar.gz
samba-31b59bbf99835279a0a78858aca2f327150eb5e2.tar.bz2
samba-31b59bbf99835279a0a78858aca2f327150eb5e2.zip
s3-dcerpc: Convert rdata from prs_struct to a simple DATA_BLOB
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/include/ntdomain.h2
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/rpc_parse/parse_prs.c12
-rw-r--r--source3/rpc_server/rpc_ncacn_np_internal.c19
-rw-r--r--source3/rpc_server/srv_pipe.c38
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c22
-rw-r--r--source3/winbindd/winbindd_dual_ndr.c13
7 files changed, 45 insertions, 63 deletions
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index d0006923ff..84b0309195 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -67,7 +67,7 @@ typedef struct _output_data {
/*
* Raw RPC output data. This does not include RPC headers or footers.
*/
- prs_struct rdata;
+ DATA_BLOB rdata;
/* The amount of data sent from the current rdata struct. */
uint32 data_sent_length;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4e36052b19..fbd3d91063 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5055,7 +5055,7 @@ bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth);
void prs_dump(const char *name, int v, prs_struct *ps);
void prs_dump_before(const char *name, int v, prs_struct *ps);
-void prs_dump_region(const char *name, int v, prs_struct *ps,
+void prs_dump_region(const char *name, int v, uint8_t *data_p,
int from_off, int to_off);
void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
bool prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, bool io);
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index ec5bc9cf6a..f8ae8d1d64 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -31,7 +31,9 @@
**/
void prs_dump(const char *name, int v, prs_struct *ps)
{
- prs_dump_region(name, v, ps, ps->data_offset, ps->buffer_size);
+ prs_dump_region(name, v,
+ (uint8_t *)ps->data_p,
+ ps->data_offset, ps->buffer_size);
}
/**
@@ -39,13 +41,15 @@ void prs_dump(const char *name, int v, prs_struct *ps)
**/
void prs_dump_before(const char *name, int v, prs_struct *ps)
{
- prs_dump_region(name, v, ps, 0, ps->data_offset);
+ prs_dump_region(name, v,
+ (uint8_t *)ps->data_p,
+ 0, ps->data_offset);
}
/**
* Dump everything from the start of the prs up to the current location.
**/
-void prs_dump_region(const char *name, int v, prs_struct *ps,
+void prs_dump_region(const char *name, int v, uint8_t *data_p,
int from_off, int to_off)
{
int fd, i;
@@ -66,7 +70,7 @@ void prs_dump_region(const char *name, int v, prs_struct *ps,
if (fd != -1 || errno != EEXIST) break;
}
if (fd != -1) {
- sz = write(fd, ps->data_p + from_off, to_off - from_off);
+ sz = write(fd, data_p + from_off, to_off - from_off);
i = close(fd);
if ( (sz != to_off-from_off) || (i != 0) ) {
DEBUG(0,("Error writing/closing %s: %ld!=%ld %d\n", fname, (unsigned long)sz, (unsigned long)to_off-from_off, i ));
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
diff --git a/source3/winbindd/winbindd_dual_ndr.c b/source3/winbindd/winbindd_dual_ndr.c
index aee5052687..08d92d45e6 100644
--- a/source3/winbindd/winbindd_dual_ndr.c
+++ b/source3/winbindd/winbindd_dual_ndr.c
@@ -266,19 +266,20 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
p.mem_ctx = talloc_stackframe();
p.in_data.data.buffer_size = state->request->extra_len;
p.in_data.data.data_p = state->request->extra_data.data;
- prs_init(&p.out_data.rdata, 0, state->mem_ctx, MARSHALL);
ret = fns[state->request->data.ndrcmd].fn(&p);
- TALLOC_FREE(p.mem_ctx);
if (!ret) {
+ TALLOC_FREE(p.mem_ctx);
return WINBINDD_ERROR;
}
state->response->extra_data.data =
- talloc_memdup(state->mem_ctx, p.out_data.rdata.data_p,
- p.out_data.rdata.data_offset);
- state->response->length += p.out_data.rdata.data_offset;
- prs_mem_free(&p.out_data.rdata);
+ talloc_move(state->mem_ctx, &p.out_data.rdata.data);
+ state->response->length += p.out_data.rdata.length;
+ p.out_data.rdata.length = 0;
+
+ TALLOC_FREE(p.mem_ctx);
+
if (state->response->extra_data.data == NULL) {
return WINBINDD_ERROR;
}