From 8213bba892c419022efdb3d800647ef3bcf51388 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 11 Jul 2010 10:47:32 -0400 Subject: s3-dcerpc: Rearrange api_pipe_bind_req() to do checks before allocating memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner --- source3/rpc_server/srv_pipe.c | 57 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index dbaaea61b9..16e1a540aa 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1530,32 +1530,6 @@ bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt) return setup_bind_nak(p, pkt); } - prs_init_empty(&p->out_data.frag, p->mem_ctx, MARSHALL); - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - /* - * Setup the memory to marshall the ba header, and the - * auth footers. - */ - - if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) { - DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); - prs_mem_free(&p->out_data.frag); - return False; - } - - if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) { - DEBUG(0,("api_pipe_bind_req: malloc out_auth failed.\n")); - prs_mem_free(&p->out_data.frag); - prs_mem_free(&out_hdr_ba); - return False; - } - if (pkt->u.bind.num_contexts == 0) { DEBUG(0, ("api_pipe_bind_req: no rpc contexts around\n")); goto err_exit; @@ -1581,9 +1555,6 @@ bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt) get_pipe_name_from_syntax( talloc_tos(), &pkt->u.bind.ctx_list[0].abstract_syntax))); - prs_mem_free(&p->out_data.frag); - prs_mem_free(&out_hdr_ba); - prs_mem_free(&out_auth); return setup_bind_nak(p, pkt); } @@ -1602,7 +1573,7 @@ bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt) &p->syntax), get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); - goto err_exit; + return setup_bind_nak(p, pkt); } } @@ -1618,6 +1589,32 @@ bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt) assoc_gid = 0x53f0; } + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init_empty(&p->out_data.frag, p->mem_ctx, MARSHALL); + + /* + * Setup the memory to marshall the ba header, and the + * auth footers. + */ + + if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + prs_mem_free(&p->out_data.frag); + return False; + } + + if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&p->out_data.frag); + prs_mem_free(&out_hdr_ba); + return False; + } + /* * Create the bind response struct. -- cgit