summaryrefslogtreecommitdiffstats
path: root/source/rpc_client
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-30 02:39:34 +0000
committerJeremy Allison <jra@samba.org>2007-04-30 02:39:34 +0000
commitc8debabda4b529f2e45b1ce0cd2941f7a34b2d84 (patch)
tree794d96398ff5d852e81b39880554c2308b2d9333 /source/rpc_client
parentf42f63fac09303f381018c34c126119f55f0fb57 (diff)
downloadsamba-c8debabda4b529f2e45b1ce0cd2941f7a34b2d84.tar.gz
samba-c8debabda4b529f2e45b1ce0cd2941f7a34b2d84.tar.xz
samba-c8debabda4b529f2e45b1ce0cd2941f7a34b2d84.zip
r22589: Make TALLOC_ARRAY consistent across all uses.
Jeremy.
Diffstat (limited to 'source/rpc_client')
-rw-r--r--source/rpc_client/cli_ds.c10
-rw-r--r--source/rpc_client/cli_lsarpc.c104
-rw-r--r--source/rpc_client/cli_samr.c12
-rw-r--r--source/rpc_client/cli_spoolss.c151
-rw-r--r--source/rpc_client/cli_srvsvc.c12
5 files changed, 187 insertions, 102 deletions
diff --git a/source/rpc_client/cli_ds.c b/source/rpc_client/cli_ds.c
index c01a5519660..5443170d8b2 100644
--- a/source/rpc_client/cli_ds.c
+++ b/source/rpc_client/cli_ds.c
@@ -98,10 +98,14 @@ NTSTATUS rpccli_ds_enum_domain_trusts(struct rpc_pipe_client *cli,
int i;
*num_domains = r.num_domains;
- *trusts = TALLOC_ARRAY(mem_ctx, struct ds_domain_trust, r.num_domains);
+ if (r.num_domains) {
+ *trusts = TALLOC_ARRAY(mem_ctx, struct ds_domain_trust, r.num_domains);
- if (*trusts == NULL) {
- return NT_STATUS_NO_MEMORY;
+ if (*trusts == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ *trusts = NULL;
}
for ( i=0; i< *num_domains; i++ ) {
diff --git a/source/rpc_client/cli_lsarpc.c b/source/rpc_client/cli_lsarpc.c
index 97d8326ede4..b31f7fc064d 100644
--- a/source/rpc_client/cli_lsarpc.c
+++ b/source/rpc_client/cli_lsarpc.c
@@ -219,22 +219,28 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
goto done;
}
- if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
- DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ if (num_sids) {
+ if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+ DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
- if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
- DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+ DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
- if (!((*types) = TALLOC_ARRAY(mem_ctx, uint32, num_sids))) {
- DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
+ if (!((*types) = TALLOC_ARRAY(mem_ctx, uint32, num_sids))) {
+ DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+ } else {
+ (*domains) = NULL;
+ (*names) = NULL;
+ (*types) = NULL;
}
for (i = 0; i < num_sids; i++) {
@@ -321,25 +327,33 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
goto done;
}
- if (!((*sids = TALLOC_ARRAY(mem_ctx, DOM_SID, num_names)))) {
- DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- if (!((*types = TALLOC_ARRAY(mem_ctx, uint32, num_names)))) {
- DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ if (num_names) {
+ if (!((*sids = TALLOC_ARRAY(mem_ctx, DOM_SID, num_names)))) {
+ DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
- if (dom_names != NULL) {
- *dom_names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
- if (*dom_names == NULL) {
+ if (!((*types = TALLOC_ARRAY(mem_ctx, uint32, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
}
+
+ if (dom_names != NULL) {
+ *dom_names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
+ if (*dom_names == NULL) {
+ DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+ }
+ } else {
+ *sids = NULL;
+ *types = NULL;
+ if (dom_names != NULL) {
+ *dom_names = NULL;
+ }
}
for (i = 0; i < num_names; i++) {
@@ -784,22 +798,28 @@ NTSTATUS rpccli_lsa_enum_privilege(struct rpc_pipe_client *cli, TALLOC_CTX *mem_
*enum_context = r.enum_context;
*count = r.count;
- if (!((*privs_name = TALLOC_ARRAY(mem_ctx, char *, r.count)))) {
- DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
+ if (r.count) {
+ if (!((*privs_name = TALLOC_ARRAY(mem_ctx, char *, r.count)))) {
+ DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
- if (!((*privs_high = TALLOC_ARRAY(mem_ctx, uint32, r.count)))) {
- DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
+ if (!((*privs_high = TALLOC_ARRAY(mem_ctx, uint32, r.count)))) {
+ DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
- if (!((*privs_low = TALLOC_ARRAY(mem_ctx, uint32, r.count)))) {
- DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
+ if (!((*privs_low = TALLOC_ARRAY(mem_ctx, uint32, r.count)))) {
+ DEBUG(0, ("(cli_lsa_enum_privilege): out of memory\n"));
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+ } else {
+ *privs_name = NULL;
+ *privs_high = NULL;
+ *privs_low = NULL;
}
for (i = 0; i < r.count; i++) {
diff --git a/source/rpc_client/cli_samr.c b/source/rpc_client/cli_samr.c
index 26b2b002d7c..444011edc5d 100644
--- a/source/rpc_client/cli_samr.c
+++ b/source/rpc_client/cli_samr.c
@@ -554,10 +554,14 @@ NTSTATUS rpccli_samr_query_useraliases(struct rpc_pipe_client *cli,
ZERO_STRUCT(q);
ZERO_STRUCT(r);
- sid_ptrs = TALLOC_ARRAY(mem_ctx, uint32, num_sids);
- if (sid_ptrs == NULL)
- return NT_STATUS_NO_MEMORY;
-
+ if (num_sids) {
+ sid_ptrs = TALLOC_ARRAY(mem_ctx, uint32, num_sids);
+ if (sid_ptrs == NULL)
+ return NT_STATUS_NO_MEMORY;
+ } else {
+ sid_ptrs = NULL;
+ }
+
for (i=0; i<num_sids; i++)
sid_ptrs[i] = 1;
diff --git a/source/rpc_client/cli_spoolss.c b/source/rpc_client/cli_spoolss.c
index 2d40f5dba1a..76a5e0b8ad4 100644
--- a/source/rpc_client/cli_spoolss.c
+++ b/source/rpc_client/cli_spoolss.c
@@ -39,11 +39,15 @@ static BOOL decode_printer_info_0(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PRINTER_INFO_0 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_0, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_0, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PRINTER_INFO_0));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PRINTER_INFO_0));
prs_set_offset(&buffer->prs,0);
@@ -66,11 +70,15 @@ static BOOL decode_printer_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PRINTER_INFO_1 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_1, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_1, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PRINTER_INFO_1));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PRINTER_INFO_1));
prs_set_offset(&buffer->prs,0);
@@ -93,11 +101,15 @@ static BOOL decode_printer_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PRINTER_INFO_2 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_2, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_2, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PRINTER_INFO_2));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PRINTER_INFO_2));
prs_set_offset(&buffer->prs,0);
@@ -122,11 +134,15 @@ static BOOL decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PRINTER_INFO_3 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_3, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_3, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PRINTER_INFO_3));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PRINTER_INFO_3));
prs_set_offset(&buffer->prs,0);
@@ -150,11 +166,15 @@ static BOOL decode_printer_info_7(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PRINTER_INFO_7 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_7, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_7, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PRINTER_INFO_7));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PRINTER_INFO_7));
prs_set_offset(&buffer->prs,0);
@@ -178,11 +198,15 @@ static BOOL decode_port_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PORT_INFO_1 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_1, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_1, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PORT_INFO_1));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PORT_INFO_1));
prs_set_offset(&buffer->prs, 0);
@@ -205,11 +229,15 @@ static BOOL decode_port_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
PORT_INFO_2 *inf;
- inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_2, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_2, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(PORT_INFO_2));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(PORT_INFO_2));
prs_set_offset(&buffer->prs, 0);
@@ -232,11 +260,15 @@ static BOOL decode_printer_driver_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
DRIVER_INFO_1 *inf;
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_1, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_1, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(DRIVER_INFO_1));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(DRIVER_INFO_1));
prs_set_offset(&buffer->prs,0);
@@ -259,11 +291,15 @@ static BOOL decode_printer_driver_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
DRIVER_INFO_2 *inf;
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_2, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_2, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(DRIVER_INFO_2));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(DRIVER_INFO_2));
prs_set_offset(&buffer->prs,0);
@@ -286,11 +322,15 @@ static BOOL decode_printer_driver_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 i;
DRIVER_INFO_3 *inf;
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_3, returned);
- if (!inf) {
- return False;
+ if (returned) {
+ inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_3, returned);
+ if (!inf) {
+ return False;
+ }
+ memset(inf, 0, returned*sizeof(DRIVER_INFO_3));
+ } else {
+ inf = NULL;
}
- memset(inf, 0, returned*sizeof(DRIVER_INFO_3));
prs_set_offset(&buffer->prs,0);
@@ -337,9 +377,13 @@ static BOOL decode_jobs_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
{
uint32 i;
- *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_1, num_jobs);
- if (*jobs == NULL) {
- return False;
+ if (num_jobs) {
+ *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_1, num_jobs);
+ if (*jobs == NULL) {
+ return False;
+ }
+ } else {
+ *jobs = NULL;
}
prs_set_offset(&buffer->prs,0);
@@ -360,9 +404,13 @@ static BOOL decode_jobs_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
{
uint32 i;
- *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_2, num_jobs);
- if (*jobs == NULL) {
- return False;
+ if (num_jobs) {
+ *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_2, num_jobs);
+ if (*jobs == NULL) {
+ return False;
+ }
+ } else {
+ *jobs = NULL;
}
prs_set_offset(&buffer->prs,0);
@@ -383,10 +431,15 @@ static BOOL decode_forms_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
{
int i;
- *forms = TALLOC_ARRAY(mem_ctx, FORM_1, num_forms);
- if (*forms == NULL) {
- return False;
+ if (num_forms) {
+ *forms = TALLOC_ARRAY(mem_ctx, FORM_1, num_forms);
+ if (*forms == NULL) {
+ return False;
+ }
+ } else {
+ *forms = NULL;
}
+
prs_set_offset(&buffer->prs,0);
for (i = 0; i < num_forms; i++) {
diff --git a/source/rpc_client/cli_srvsvc.c b/source/rpc_client/cli_srvsvc.c
index 7b4818b4b06..e471de7c3ba 100644
--- a/source/rpc_client/cli_srvsvc.c
+++ b/source/rpc_client/cli_srvsvc.c
@@ -545,11 +545,15 @@ WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_
switch(file_level) {
case 3:
- if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
- return WERR_NOMEM;
- }
+ if (ctr->num_entries) {
+ if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
+ return WERR_NOMEM;
+ }
- memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
+ memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
+ } else {
+ ctr->file.info3 = NULL;
+ }
for (i = 0; i < r.ctr.num_entries; i++) {
FILE_INFO_3 *info3 = &ctr->file.info3[i];