summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_pipe.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-12-07 18:25:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:32 -0500
commitacf9d61421faa6c0055d57fdee7db300dc5431aa (patch)
tree5482afecfe9b4a68b9a1f18d541a3109f8143ab7 /source3/rpc_server/srv_pipe.c
parent3bd3be97dc8a581c0502410453091c195e322766 (diff)
downloadsamba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.gz
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.bz2
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.zip
r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
Diffstat (limited to 'source3/rpc_server/srv_pipe.c')
-rw-r--r--source3/rpc_server/srv_pipe.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index bcf5eb533f..01e91ce6c5 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -775,7 +775,7 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract,
int n_fns = 0;
PIPE_RPC_FNS *context_fns;
- if ( !(context_fns = malloc(sizeof(PIPE_RPC_FNS))) ) {
+ if ( !(context_fns = SMB_MALLOC_P(PIPE_RPC_FNS)) ) {
DEBUG(0,("check_bind_req: malloc() failed!\n"));
return False;
}
@@ -831,8 +831,8 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s
/* We use a temporary variable because this call can fail and
rpc_lookup will still be valid afterwards. It could then succeed if
called again later */
- rpc_entry = realloc(rpc_lookup,
- ++rpc_lookup_size*sizeof(struct rpc_table));
+ rpc_lookup_size++;
+ rpc_entry = SMB_REALLOC_ARRAY(rpc_lookup, struct rpc_table, rpc_lookup_size);
if (NULL == rpc_entry) {
rpc_lookup_size--;
DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n"));
@@ -843,13 +843,10 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s
rpc_entry = rpc_lookup + (rpc_lookup_size - 1);
ZERO_STRUCTP(rpc_entry);
- rpc_entry->pipe.clnt = strdup(clnt);
- rpc_entry->pipe.srv = strdup(srv);
- rpc_entry->cmds = realloc(rpc_entry->cmds,
- (rpc_entry->n_cmds + size) *
- sizeof(struct api_struct));
- memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds,
- size * sizeof(struct api_struct));
+ rpc_entry->pipe.clnt = SMB_STRDUP(clnt);
+ rpc_entry->pipe.srv = SMB_STRDUP(srv);
+ rpc_entry->cmds = SMB_REALLOC_ARRAY(rpc_entry->cmds, struct api_struct, rpc_entry->n_cmds + size);
+ memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, size * sizeof(struct api_struct));
rpc_entry->n_cmds += size;
return NT_STATUS_OK;
@@ -1585,9 +1582,7 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name,
if ((DEBUGLEVEL >= 10) &&
(prs_offset(&p->in_data.data) != prs_data_size(&p->in_data.data))) {
size_t data_len = prs_data_size(&p->in_data.data) - prs_offset(&p->in_data.data);
- char *data;
-
- data = malloc(data_len);
+ char *data = SMB_MALLOC(data_len);
DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n"));
if (data) {