summaryrefslogtreecommitdiff
path: root/source3/rpcclient
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/rpcclient
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/rpcclient')
-rw-r--r--source3/rpcclient/cmd_echo.c4
-rw-r--r--source3/rpcclient/cmd_lsarpc.c2
-rw-r--r--source3/rpcclient/cmd_samr.c4
-rw-r--r--source3/rpcclient/cmd_spoolss.c7
-rw-r--r--source3/rpcclient/rpcclient.c10
5 files changed, 13 insertions, 14 deletions
diff --git a/source3/rpcclient/cmd_echo.c b/source3/rpcclient/cmd_echo.c
index fa4e691663..fce8e4c7b8 100644
--- a/source3/rpcclient/cmd_echo.c
+++ b/source3/rpcclient/cmd_echo.c
@@ -60,7 +60,7 @@ static NTSTATUS cmd_echo_data(struct cli_state *cli, TALLOC_CTX *mem_ctx,
}
size = atoi(argv[1]);
- in_data = malloc(size);
+ in_data = SMB_MALLOC(size);
for (i = 0; i < size; i++)
in_data[i] = i & 0xff;
@@ -129,7 +129,7 @@ static NTSTATUS cmd_echo_sink_data(struct cli_state *cli, TALLOC_CTX *mem_ctx,
}
size = atoi(argv[1]);
- in_data = malloc(size);
+ in_data = SMB_MALLOC(size);
for (i = 0; i < size; i++)
in_data[i] = i & 0xff;
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index d9afde465d..2b8279ccd2 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -207,7 +207,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/* Convert arguments to sids */
- sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * (argc - 1));
+ sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);
if (!sids) {
printf("could not allocate memory for %d sids\n", argc - 1);
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 6ab08e1991..3bd55aff06 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1238,7 +1238,7 @@ static NTSTATUS cmd_samr_lookup_names(struct cli_state *cli,
/* Look up names */
num_names = argc - 2;
- names = (const char **)talloc(mem_ctx, sizeof(char *) * num_names);
+ names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
for (i = 0; i < argc - 2; i++)
names[i] = argv[i + 2];
@@ -1296,7 +1296,7 @@ static NTSTATUS cmd_samr_lookup_rids(struct cli_state *cli,
/* Look up rids */
num_rids = argc - 1;
- rids = (uint32 *)talloc(mem_ctx, sizeof(uint32) * num_rids);
+ rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids);
for (i = 0; i < argc - 1; i++)
sscanf(argv[i + 1], "%i", &rids[i]);
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 4c4704c4ae..0b0d015238 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -1333,7 +1333,7 @@ static BOOL init_drv_info_3_members (
/* allocate the space; add one extra slot for a terminating NULL.
Each filename is NULL terminated and the end contains a double
NULL */
- if ((info->dependentfiles=(uint16*)talloc(mem_ctx, (len+1)*sizeof(uint16))) == NULL)
+ if ((info->dependentfiles=TALLOC_ARRAY(mem_ctx, uint16, len+1)) == NULL)
{
DEBUG(0,("init_drv_info_3_members: Unable to malloc memory for dependenfiles\n"));
return False;
@@ -2035,7 +2035,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli,
fstrcpy(value.valuename, argv[2]);
value.type = REG_SZ;
value.size = data.uni_str_len * 2;
- value.data_p = talloc_memdup(mem_ctx, data.buffer, value.size);
+ value.data_p = TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
result = cli_spoolss_setprinterdata(cli, mem_ctx, &pol, &value);
@@ -2417,8 +2417,7 @@ static WERROR cmd_spoolss_rffpcnex(struct cli_state *cli,
option.option_type_ptr = 1;
option.count = option.ctr.count = 2;
- option.ctr.type = (SPOOL_NOTIFY_OPTION_TYPE *)talloc(
- mem_ctx, sizeof(SPOOL_NOTIFY_OPTION_TYPE) * 2);
+ option.ctr.type = TALLOC_ARRAY(mem_ctx, SPOOL_NOTIFY_OPTION_TYPE, 2);
ZERO_STRUCT(option.ctr.type[0]);
option.ctr.type[0].type = PRINTER_NOTIFY_TYPE;
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index bac11f7435..e003b86e67 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -59,10 +59,10 @@ static char **completion_fn(const char *text, int start, int end)
if (!commands)
return NULL;
- matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS);
+ matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
if (!matches) return NULL;
- matches[count++] = strdup(text);
+ matches[count++] = SMB_STRDUP(text);
if (!matches[0]) return NULL;
while (commands && count < MAX_COMPLETIONS-1)
@@ -78,7 +78,7 @@ static char **completion_fn(const char *text, int start, int end)
( commands->cmd_set[i].returntype == RPC_RTYPE_WERROR &&
commands->cmd_set[i].wfn)))
{
- matches[count] = strdup(commands->cmd_set[i].name);
+ matches[count] = SMB_STRDUP(commands->cmd_set[i].name);
if (!matches[count])
return NULL;
count++;
@@ -91,7 +91,7 @@ static char **completion_fn(const char *text, int start, int end)
if (count == 2) {
SAFE_FREE(matches[0]);
- matches[0] = strdup(matches[1]);
+ matches[0] = SMB_STRDUP(matches[1]);
}
matches[count] = NULL;
return matches;
@@ -485,7 +485,7 @@ static void add_command_set(struct cmd_set *cmd_set)
{
struct cmd_list *entry;
- if (!(entry = (struct cmd_list *)malloc(sizeof(struct cmd_list)))) {
+ if (!(entry = SMB_MALLOC_P(struct cmd_list))) {
DEBUG(0, ("out of memory\n"));
return;
}