summaryrefslogtreecommitdiffstats
path: root/source/rpc_client/cli_samr.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-04-25 02:02:01 +0000
committerTim Potter <tpot@samba.org>2003-04-25 02:02:01 +0000
commitaa748e1da543f0e59df8a56996ebd9510732507e (patch)
treeb28c100d167ef1839845f5b9c27215bce9270903 /source/rpc_client/cli_samr.c
parent4998a72cf8e3a2b254dc409a36b9bbd118bdc4fd (diff)
downloadsamba-aa748e1da543f0e59df8a56996ebd9510732507e.tar.gz
samba-aa748e1da543f0e59df8a56996ebd9510732507e.tar.xz
samba-aa748e1da543f0e59df8a56996ebd9510732507e.zip
Minor cleanup of enum domain groups/aliases:
- return NT_STATUS_NO_MEMORY instead of NT_STATUS_UNSUCESSFUL if a talloc fails - don't try and tallocate memory when the number of entries returned was zero - rename some cut&pasted variable names in enum domain aliases function
Diffstat (limited to 'source/rpc_client/cli_samr.c')
-rw-r--r--source/rpc_client/cli_samr.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source/rpc_client/cli_samr.c b/source/rpc_client/cli_samr.c
index fa4c662e045..767c6a12b25 100644
--- a/source/rpc_client/cli_samr.c
+++ b/source/rpc_client/cli_samr.c
@@ -677,13 +677,16 @@ NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
*num_dom_groups = r.num_entries2;
+ if (*num_dom_groups == 0)
+ goto done;
+
if (!((*dom_groups) = (struct acct_info *)
talloc(mem_ctx, sizeof(struct acct_info) * *num_dom_groups))) {
- result = NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_NO_MEMORY;
goto done;
}
- memset(*dom_groups, 0, sizeof(struct acct_info) * *num_dom_groups);
+ memset(*dom_groups, 0, sizeof(struct acct_info) * (*num_dom_groups));
name_idx = 0;
@@ -712,8 +715,8 @@ NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
NTSTATUS cli_samr_enum_als_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *pol, uint32 *start_idx,
- uint32 size, struct acct_info **dom_groups,
- uint32 *num_dom_groups)
+ uint32 size, struct acct_info **dom_aliases,
+ uint32 *num_dom_aliases)
{
prs_struct qbuf, rbuf;
SAMR_Q_ENUM_DOM_ALIASES q;
@@ -753,24 +756,27 @@ NTSTATUS cli_samr_enum_als_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
goto done;
}
- *num_dom_groups = r.num_entries2;
+ *num_dom_aliases = r.num_entries2;
- if (!((*dom_groups) = (struct acct_info *)
- talloc(mem_ctx, sizeof(struct acct_info) * *num_dom_groups))) {
- result = NT_STATUS_UNSUCCESSFUL;
+ if (*num_dom_aliases == 0)
+ goto done;
+
+ if (!((*dom_aliases) = (struct acct_info *)
+ talloc(mem_ctx, sizeof(struct acct_info) * *num_dom_aliases))) {
+ result = NT_STATUS_NO_MEMORY;
goto done;
}
- memset(*dom_groups, 0, sizeof(struct acct_info) * *num_dom_groups);
+ memset(*dom_aliases, 0, sizeof(struct acct_info) * *num_dom_aliases);
name_idx = 0;
- for (i = 0; i < *num_dom_groups; i++) {
+ for (i = 0; i < *num_dom_aliases; i++) {
- (*dom_groups)[i].rid = r.sam[i].rid;
+ (*dom_aliases)[i].rid = r.sam[i].rid;
if (r.sam[i].hdr_name.buffer) {
- unistr2_to_ascii((*dom_groups)[i].acct_name,
+ unistr2_to_ascii((*dom_aliases)[i].acct_name,
&r.uni_grp_name[name_idx],
sizeof(fstring) - 1);
name_idx++;