summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_ds.c10
-rw-r--r--source3/rpc_client/cli_lsarpc.c104
-rw-r--r--source3/rpc_client/cli_samr.c12
-rw-r--r--source3/rpc_client/cli_spoolss.c151
4 files changed, 179 insertions, 98 deletions
diff --git a/source3/rpc_client/cli_ds.c b/source3/rpc_client/cli_ds.c
index c01a551966..5443170d8b 100644
--- a/source3/rpc_client/cli_ds.c
+++ b/source3/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/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 1f6daa1721..00b91e4a3c 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -179,22 +179,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, enum lsa_SidType, 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, enum lsa_SidType, 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++) {
@@ -281,25 +287,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, enum lsa_SidType, 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, enum lsa_SidType, 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++) {
@@ -744,22 +758,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/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 593b0f385b..462add4381 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -536,10 +536,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/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 2d40f5dba1..76a5e0b8ad 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/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++) {