From 14bae61ba36814ea5eca7c51cf1cc039e9e6803f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 18 Feb 2013 16:36:22 +0100 Subject: winbind: Use talloc for allocating domain, dns, forest and dc name. Reviewed-by: David Disseldorp --- source3/winbindd/winbindd_util.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'source3/winbindd/winbindd_util.c') diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index c32feb8951..4759fd5109 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -67,7 +67,7 @@ static void free_domain_list(void) struct winbindd_domain *next = domain->next; DLIST_REMOVE(_domain_list, domain); - SAFE_FREE(domain); + TALLOC_FREE(domain); domain = next; } } @@ -156,27 +156,31 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const } /* Create new domain entry */ - - if ((domain = SMB_MALLOC_P(struct winbindd_domain)) == NULL) + domain = talloc_zero(NULL, struct winbindd_domain); + if (domain == NULL) { return NULL; + } - /* Fill in fields */ - - ZERO_STRUCTP(domain); - - domain->children = SMB_MALLOC_ARRAY( - struct winbindd_child, lp_winbind_max_domain_connections()); + domain->children = talloc_zero_array(domain, + struct winbindd_child, + lp_winbind_max_domain_connections()); if (domain->children == NULL) { - SAFE_FREE(domain); + TALLOC_FREE(domain); + return NULL; + } + + domain->name = talloc_strdup(domain, domain_name); + if (domain->name == NULL) { + TALLOC_FREE(domain); return NULL; } - memset(domain->children, 0, - sizeof(struct winbindd_child) - * lp_winbind_max_domain_connections()); - fstrcpy(domain->name, domain_name); if (alternative_name) { - fstrcpy(domain->alt_name, alternative_name); + domain->alt_name = talloc_strdup(domain, alternative_name); + if (domain->alt_name == NULL) { + TALLOC_FREE(domain); + return NULL; + } } domain->methods = methods; -- cgit