From e2c9fc4cf5f0ff725330fa44f53782db65fca37e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 4 Feb 2008 20:57:35 +0100 Subject: [PATCH] Always pass a TALLOC_CTX to str_list_make and str_list_copy --- source/auth/auth.c | 36 ++++++++++++++++++++++++++---------- source/lib/debug.c | 6 +++--- source/lib/util_str.c | 13 +++---------- source/libads/ldap.c | 4 ++-- source/libgpo/gpo_ldap.c | 6 +++--- source/param/loadparm.c | 17 ++++++++++------- source/smbd/map_username.c | 6 +++--- source/smbd/password.c | 9 +++++---- source/web/neg_lang.c | 4 ++-- 9 files changed, 57 insertions(+), 44 deletions(-) diff --git a/source/auth/auth.c b/source/auth/auth.c index e136fc2f045..05bb6a5af0c 100644 --- a/source/auth/auth.c +++ b/source/auth/auth.c @@ -458,7 +458,9 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) char **auth_method_list = NULL; NTSTATUS nt_status; - if (lp_auth_methods() && !str_list_copy(&auth_method_list, lp_auth_methods())) { + if (lp_auth_methods() + && !str_list_copy(talloc_tos(), &auth_method_list, + lp_auth_methods())) { return NT_STATUS_NO_MEMORY; } @@ -467,38 +469,52 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) { case SEC_DOMAIN: DEBUG(5,("Making default auth method list for security=domain\n")); - auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest sam winbind:ntdomain", + NULL); break; case SEC_SERVER: DEBUG(5,("Making default auth method list for security=server\n")); - auth_method_list = str_list_make("guest sam smbserver", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest sam smbserver", + NULL); break; case SEC_USER: if (lp_encrypted_passwords()) { if ((lp_server_role() == ROLE_DOMAIN_PDC) || (lp_server_role() == ROLE_DOMAIN_BDC)) { DEBUG(5,("Making default auth method list for DC, security=user, encrypt passwords = yes\n")); - auth_method_list = str_list_make("guest sam winbind:trustdomain", NULL); + auth_method_list = str_list_make( + talloc_tos(), + "guest sam winbind:trustdomain", + NULL); } else { DEBUG(5,("Making default auth method list for standalone security=user, encrypt passwords = yes\n")); - auth_method_list = str_list_make("guest sam", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest sam", + NULL); } } else { DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n")); - auth_method_list = str_list_make("guest unix", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest unix", NULL); } break; case SEC_SHARE: if (lp_encrypted_passwords()) { DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n")); - auth_method_list = str_list_make("guest sam", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest sam", NULL); } else { DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n")); - auth_method_list = str_list_make("guest unix", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest unix", NULL); } break; case SEC_ADS: DEBUG(5,("Making default auth method list for security=ADS\n")); - auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL); + auth_method_list = str_list_make( + talloc_tos(), "guest sam winbind:ntdomain", + NULL); break; default: DEBUG(5,("Unknown auth method!\n")); @@ -511,7 +527,7 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) nt_status = make_auth_context_text_list(auth_context, auth_method_list); - str_list_free(&auth_method_list); + TALLOC_FREE(auth_method_list); return nt_status; } diff --git a/source/lib/debug.c b/source/lib/debug.c index 51bb0d75418..9ff267b6079 100644 --- a/source/lib/debug.c +++ b/source/lib/debug.c @@ -460,14 +460,14 @@ bool debug_parse_levels(const char *params_str) if (AllowDebugChange == False) return True; - params = str_list_make(params_str, NULL); + params = str_list_make(talloc_tos(), params_str, NULL); if (debug_parse_params(params)) { debug_dump_status(5); - str_list_free(¶ms); + TALLOC_FREE(params); return True; } else { - str_list_free(¶ms); + TALLOC_FREE(params); return False; } } diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 05be7ca1e41..fb3392f0410 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -1902,19 +1902,12 @@ static char **str_list_make_internal(TALLOC_CTX *mem_ctx, const char *string, return list; } -char **str_list_make_talloc(TALLOC_CTX *mem_ctx, - const char *string, - const char *sep) +char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { return str_list_make_internal(mem_ctx, string, sep); } -char **str_list_make(const char *string, const char *sep) -{ - return str_list_make_internal(NULL, string, sep); -} - -bool str_list_copy(char ***dest, const char **src) +bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src) { char **list; int i, num; @@ -1928,7 +1921,7 @@ bool str_list_copy(char ***dest, const char **src) num += 1; } - list = TALLOC_ARRAY(NULL, char *, num+1); + list = TALLOC_ARRAY(mem_ctx, char *, num+1); if (list == NULL) { return false; } diff --git a/source/libads/ldap.c b/source/libads/ldap.c index 7b0adc2fc33..ef6feb8ee06 100644 --- a/source/libads/ldap.c +++ b/source/libads/ldap.c @@ -664,7 +664,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(&search_attrs, attrs))) { + if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) { rc = LDAP_NO_MEMORY; goto done; } @@ -974,7 +974,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(&search_attrs, attrs))) + if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) { DEBUG(1,("ads_do_search: str_list_copy() failed!")); rc = LDAP_NO_MEMORY; diff --git a/source/libgpo/gpo_ldap.c b/source/libgpo/gpo_ldap.c index 4e63b92e4ef..1d6b2756638 100644 --- a/source/libgpo/gpo_ldap.c +++ b/source/libgpo/gpo_ldap.c @@ -44,7 +44,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, goto parse_error; } - ext_list = str_list_make_talloc(mem_ctx, extension_raw, "]"); + ext_list = str_list_make(mem_ctx, extension_raw, "]"); if (!ext_list) { goto parse_error; } @@ -87,7 +87,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, p++; } - ext_strings = str_list_make_talloc(mem_ctx, p, "}"); + ext_strings = str_list_make(mem_ctx, p, "}"); if (ext_strings == NULL) { goto parse_error; } @@ -166,7 +166,7 @@ static ADS_STATUS gpo_parse_gplink(TALLOC_CTX *mem_ctx, DEBUG(10,("gpo_parse_gplink: gPLink: %s\n", gp_link_raw)); - link_list = str_list_make_talloc(mem_ctx, gp_link_raw, "]"); + link_list = str_list_make(mem_ctx, gp_link_raw, "]"); if (!link_list) { goto parse_error; } diff --git a/source/param/loadparm.c b/source/param/loadparm.c index c1d26af9897..5ecb3a4e70b 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -1691,7 +1691,7 @@ static void init_globals(bool first_time_only) Globals.bWinbindTrustedDomainsOnly = False; Globals.bWinbindNestedGroups = True; Globals.winbind_expand_groups = 1; - Globals.szWinbindNssInfo = str_list_make("template", NULL); + Globals.szWinbindNssInfo = str_list_make(NULL, "template", NULL); Globals.bWinbindRefreshTickets = False; Globals.bWinbindOfflineLogon = False; @@ -2397,7 +2397,7 @@ const char **lp_parm_string_list(int snum, const char *type, const char *option, return (const char **)def; if (data->list==NULL) { - data->list = str_list_make(data->value, NULL); + data->list = str_list_make(NULL, data->value, NULL); } return (const char **)data->list; @@ -3276,7 +3276,8 @@ static void copy_service(service * pserviceDest, service * pserviceSource, break; case P_LIST: str_list_free((char ***)dest_ptr); - str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr); + str_list_copy(NULL, (char ***)dest_ptr, + *(const char ***)src_ptr); break; default: break; @@ -3775,7 +3776,7 @@ static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr) static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr) { str_list_free(&Globals.szNetbiosAliases); - Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL); + Globals.szNetbiosAliases = str_list_make(NULL, pszParmValue, NULL); return set_netbios_aliases((const char **)Globals.szNetbiosAliases); } @@ -4193,7 +4194,8 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue case P_LIST: str_list_free((char ***)parm_ptr); - *(char ***)parm_ptr = str_list_make(pszParmValue, NULL); + *(char ***)parm_ptr = str_list_make( + NULL, pszParmValue, NULL); break; case P_STRING: @@ -4812,8 +4814,9 @@ static void lp_save_defaults(void) continue; switch (parm_table[i].type) { case P_LIST: - str_list_copy(&(parm_table[i].def.lvalue), - *(const char ***)parm_table[i].ptr); + str_list_copy( + NULL, &(parm_table[i].def.lvalue), + *(const char ***)parm_table[i].ptr); break; case P_STRING: case P_USTRING: diff --git a/source/smbd/map_username.c b/source/smbd/map_username.c index 7290f705472..7536758bcb6 100644 --- a/source/smbd/map_username.c +++ b/source/smbd/map_username.c @@ -178,7 +178,7 @@ bool map_username(fstring user) /* skip lines like 'user = ' */ - dosuserlist = str_list_make(dosname, NULL); + dosuserlist = str_list_make(talloc_tos(), dosname, NULL); if (!dosuserlist) { DEBUG(0,("Bad username map entry. Unable to build user list. Ignoring.\n")); continue; @@ -193,13 +193,13 @@ bool map_username(fstring user) fstrcpy( user, unixname ); if ( return_if_mapped ) { - str_list_free (&dosuserlist); + TALLOC_FREE(dosuserlist); x_fclose(f); return True; } } - str_list_free (&dosuserlist); + TALLOC_FREE(dosuserlist); } x_fclose(f); diff --git a/source/smbd/password.c b/source/smbd/password.c index 85e1ccf0a7f..913c3c35da8 100644 --- a/source/smbd/password.c +++ b/source/smbd/password.c @@ -582,7 +582,7 @@ static bool user_ok(const char *user, int snum) ret = True; if (lp_invalid_users(snum)) { - str_list_copy(&invalid, lp_invalid_users(snum)); + str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum)); if (invalid && str_list_substitute(invalid, "%S", lp_servicename(snum))) { @@ -599,7 +599,7 @@ static bool user_ok(const char *user, int snum) str_list_free (&invalid); if (ret && lp_valid_users(snum)) { - str_list_copy(&valid, lp_valid_users(snum)); + str_list_copy(talloc_tos(), &valid, lp_valid_users(snum)); if ( valid && str_list_substitute(valid, "%S", lp_servicename(snum)) ) { @@ -615,13 +615,14 @@ static bool user_ok(const char *user, int snum) str_list_free (&valid); if (ret && lp_onlyuser(snum)) { - char **user_list = str_list_make (lp_username(snum), NULL); + char **user_list = str_list_make( + talloc_tos(), lp_username(snum), NULL); if (user_list && str_list_substitute(user_list, "%S", lp_servicename(snum))) { ret = user_in_list(user, (const char **)user_list); } - if (user_list) str_list_free (&user_list); + TALLOC_FREE(user_list); } return(ret); diff --git a/source/web/neg_lang.c b/source/web/neg_lang.c index bb481306e73..82411000cd1 100644 --- a/source/web/neg_lang.c +++ b/source/web/neg_lang.c @@ -74,7 +74,7 @@ void web_set_lang(const char *lang_string) int lang_num, i; /* build the lang list */ - lang_list = str_list_make(lang_string, ", \t\r\n"); + lang_list = str_list_make(talloc_tos(), lang_string, ", \t\r\n"); if (!lang_list) return; /* sort the list by priority */ @@ -100,7 +100,7 @@ void web_set_lang(const char *lang_string) } pl[i].string = SMB_STRDUP(lang_list[i]); } - str_list_free(&lang_list); + TALLOC_FREE(lang_list); qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);