summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-04-25 01:52:52 +0000
committerTim Potter <tpot@samba.org>2003-04-25 01:52:52 +0000
commitcc5121f9e53bc2803b61aea873e8e65f971b1e51 (patch)
treefe9a38f294838b08a7b98d1aa700ed36e37750fb /source3
parentf1e92738b2464d4833e1d41f0d82aef2dd071583 (diff)
downloadsamba-cc5121f9e53bc2803b61aea873e8e65f971b1e51.tar.gz
samba-cc5121f9e53bc2803b61aea873e8e65f971b1e51.tar.bz2
samba-cc5121f9e53bc2803b61aea873e8e65f971b1e51.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 (This used to be commit cb94b2b2d141c3df1209b2b389b0cd6752ac2b6b)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_client/cli_samr.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index fa4c662e04..767c6a12b2 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/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++;