summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_pipe.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
committerJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
commit5ec1642809d9de83da8c88c65d6595c6eb0270f5 (patch)
treef6f4f1e0b3678394fca8b7c37f71084a1b166671 /source3/rpc_client/cli_pipe.c
parent134a4b86548db77cba292c50fbd6b91ecaa69f14 (diff)
downloadsamba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.gz
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.bz2
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.zip
Ok - this is a *BIG* change - but it fixes the problems with static strings
in the RPC code. This change was prompted by trying to save a long (>256) character comment in the printer properties page. The new system associates a TALLOC_CTX with the pipe struct, and frees the pool on return of a complete PDU. A global TALLOC_CTX is used for the odd buffer allocated in the BUFFERxx code, and is freed in the main loop. This code works with insure, and seems to be free of memory leaks and crashes (so far) but there are probably the occasional problem with code that uses UNISTRxx structs on the stack and expects them to contain storage without doing a init_unistrXX(). This means that rpcclient will probably be horribly broken. A TALLOC_CTX also needed associating with the struct cli_state also, to make the prs_xx code there work. The main interface change is the addition of a TALLOC_CTX to the prs_init calls - used for dynamic allocation in the prs_XXX calls. Now this is in place it should make dynamic allocation of all RPC memory on unmarshall *much* easier to fix. Jeremy. (This used to be commit 0ff2ce543ee54f7364e6d839db6d06e7ef1edcf4)
Diffstat (limited to 'source3/rpc_client/cli_pipe.c')
-rw-r--r--source3/rpc_client/cli_pipe.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index ade31dbb5b..8136b7894c 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -223,7 +223,7 @@ static BOOL rpc_auth_pipe(struct cli_state *cli, prs_struct *rdata, int len, int
memcpy(data, dp, sizeof(data));
- prs_init(&auth_req , 0, 4, UNMARSHALL);
+ prs_init(&auth_req , 0, 4, cli->mem_ctx, UNMARSHALL);
prs_give_memory(&auth_req, data, RPC_HDR_AUTH_LEN, False);
/*
@@ -267,7 +267,7 @@ static BOOL rpc_auth_pipe(struct cli_state *cli, prs_struct *rdata, int len, int
memcpy(data, dp, RPC_AUTH_NTLMSSP_CHK_LEN);
dump_data(100, data, auth_len);
- prs_init(&auth_verf, 0, 4, UNMARSHALL);
+ prs_init(&auth_verf, 0, 4, cli->mem_ctx, UNMARSHALL);
prs_give_memory(&auth_verf, data, RPC_AUTH_NTLMSSP_CHK_LEN, False);
if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &chk, &auth_verf, 0)) {
@@ -446,7 +446,7 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *data, pr
* First read the header of the next PDU.
*/
- prs_init(&hps, 0, 4, UNMARSHALL);
+ prs_init(&hps, 0, 4, cli->mem_ctx, UNMARSHALL);
prs_give_memory(&hps, hdr_data, sizeof(hdr_data), False);
num_read = cli_read(cli, cli->nt_pipe_fnum, hdr_data, 0, RPC_HEADER_LEN+RPC_HDR_RESP_LEN);
@@ -522,7 +522,7 @@ static BOOL create_rpc_bind_req(prs_struct *rpc_out, BOOL do_auth, uint32 rpc_ca
prs_struct auth_info;
int auth_len = 0;
- prs_init(&auth_info, 0, 4, MARSHALL);
+ prs_init(&auth_info, 0, 4, prs_get_mem_context(rpc_out), MARSHALL);
if (do_auth) {
RPC_HDR_AUTH hdr_auth;
@@ -626,7 +626,7 @@ static BOOL create_rpc_bind_resp(struct pwd_info *pwd,
* Marshall the variable length data into a temporary parse
* struct, pointing into a 4k local buffer.
*/
- prs_init(&auth_info, 0, 4, MARSHALL);
+ prs_init(&auth_info, 0, 4, prs_get_mem_context(rpc_out), MARSHALL);
/*
* Use the 4k buffer to store the auth info.
@@ -784,7 +784,7 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
* Malloc a parse struct to hold it (and enough for alignments).
*/
- if(!prs_init(&outgoing_packet, data_len + 8, 4, MARSHALL)) {
+ if(!prs_init(&outgoing_packet, data_len + 8, 4, cli->mem_ctx, MARSHALL)) {
DEBUG(0,("rpc_api_pipe_req: Failed to malloc %u bytes.\n", (unsigned int)data_len ));
return False;
}
@@ -1022,7 +1022,7 @@ static BOOL rpc_send_auth_reply(struct cli_state *cli, prs_struct *rdata, uint32
pwd_make_lm_nt_owf(&cli->pwd, rhdr_chal.challenge);
- prs_init(&rpc_out, 0, 4, MARSHALL);
+ prs_init(&rpc_out, 0, 4, cli->mem_ctx, MARSHALL);
prs_give_memory( &rpc_out, buffer, sizeof(buffer), False);
@@ -1094,7 +1094,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, char *my_name)
if (!valid_pipe_name(pipe_name, &abstract, &transfer))
return False;
- prs_init(&rpc_out, 0, 4, MARSHALL);
+ prs_init(&rpc_out, 0, 4, cli->mem_ctx, MARSHALL);
/*
* Use the MAX_PDU_FRAG_LEN buffer to store the bind request.
@@ -1110,7 +1110,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, char *my_name)
global_myname, cli->domain, cli->ntlmssp_cli_flgs);
/* Initialize the incoming data struct. */
- prs_init(&rdata, 0, 4, UNMARSHALL);
+ prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
/* send data on \PIPE\. receive a response */
if (rpc_api_pipe(cli, 0x0026, &rpc_out, &rdata)) {