diff options
author | Ralph Boehme <slow@samba.org> | 2015-08-04 11:18:34 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2015-08-17 20:01:19 +0200 |
commit | 0c640d097fe6f83f3585d76f875c5fb0cade26af (patch) | |
tree | cdebba5d55faa49c93030afe64b2a3e2c5bb582f | |
parent | 49e39b05ca637cce4621ac60ed3bb536c0ac544a (diff) | |
download | samba-0c640d097fe6f83f3585d76f875c5fb0cade26af.tar.gz |
s3-net: use talloc array in share allowedusers
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11426
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Aug 4 16:48:36 CEST 2015 on sn-devel-104
(cherry picked from commit 95eb6db580678a29b1f5f30a9567ea449a43d75a)
Autobuild-User(v4-1-test): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(v4-1-test): Mon Aug 17 20:01:19 CEST 2015 on sn-devel-104
-rw-r--r-- | source3/utils/net_rpc.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index c5c4d6c2931..48c85c272f7 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -4342,10 +4342,25 @@ static struct full_alias *server_aliases; /* * Add an alias to the static list. */ -static void push_alias(TALLOC_CTX *mem_ctx, struct full_alias *alias) +static void push_alias(struct full_alias *alias) { - if (server_aliases == NULL) - server_aliases = SMB_MALLOC_ARRAY(struct full_alias, 100); + size_t array_size; + + if (server_aliases == NULL) { + server_aliases = talloc_array(NULL, struct full_alias, 100); + if (server_aliases == NULL) { + smb_panic("talloc_array failed"); + } + } + + array_size = talloc_array_length(server_aliases); + if (array_size == num_server_aliases) { + server_aliases = talloc_realloc(NULL, server_aliases, + struct full_alias, array_size + 100); + if (server_aliases == NULL) { + smb_panic("talloc_realloc failed"); + } + } server_aliases[num_server_aliases] = *alias; num_server_aliases += 1; @@ -4454,7 +4469,7 @@ static NTSTATUS rpc_fetch_domain_aliases(struct rpc_pipe_client *pipe_hnd, sid_compose(&alias.sid, domain_sid, groups->entries[i].idx); - push_alias(mem_ctx, &alias); + push_alias(&alias); } } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); @@ -5084,6 +5099,7 @@ static NTSTATUS rpc_share_allowedusers_internals(struct net_context *c, free_user_token(&tokens[i].token); } SAFE_FREE(tokens); + TALLOC_FREE(server_aliases); return nt_status; } |