From 3b3e21bd9ba701a97e752205263a7903619541c7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 19 Mar 2009 12:20:11 +1100 Subject: Convert Samba3 to use the common lib/util/charset API This removes calls to push_*_allocate() and pull_*_allocate(), as well as convert_string_allocate, as they are not in the common API To allow transition to a common charcnv in future, provide Samba4-like strupper functions in source3/lib/charcnv.c (the actual implementation remains distinct, but the API is now shared) Andrew Bartlett --- source3/utils/net_conf.c | 6 +++--- source3/utils/net_usershare.c | 12 ++++++------ source3/utils/ntlm_auth_diagnostics.c | 26 +++++++++++++------------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index b65202ee69..3fa547baf4 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -766,7 +766,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx, d_printf("error: out of memory!\n"); goto done; } - param = talloc_strdup_lower(mem_ctx, argv[1]); + param = strlower_talloc(mem_ctx, argv[1]); if (param == NULL) { d_printf("error: out of memory!\n"); goto done; @@ -818,7 +818,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx, d_printf("error: out of memory!\n"); goto done; } - param = talloc_strdup_lower(mem_ctx, argv[1]); + param = strlower_talloc(mem_ctx, argv[1]); if (param == NULL) { d_printf("error: out of memory!\n"); goto done; @@ -868,7 +868,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx, d_printf("error: out of memory!\n"); goto done; } - param = talloc_strdup_lower(mem_ctx, argv[1]); + param = strlower_talloc(mem_ctx, argv[1]); if (param == NULL) { d_printf("error: out of memory!\n"); goto done; diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index ce8e82182e..7d3cb287a8 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -154,8 +154,8 @@ static int net_usershare_delete(struct net_context *c, int argc, const char **ar return net_usershare_delete_usage(c, argc, argv); } - if ((sharename = strdup_lower(argv[0])) == NULL) { - d_fprintf(stderr, "strdup failed\n"); + if ((sharename = strlower_talloc(talloc_tos(), argv[0])) == NULL) { + d_fprintf(stderr, "strlower_talloc failed\n"); return -1; } @@ -624,22 +624,22 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv) default: return net_usershare_add_usage(c, argc, argv); case 2: - sharename = strdup_lower(argv[0]); + sharename = strlower_talloc(ctx, argv[0]); us_path = argv[1]; break; case 3: - sharename = strdup_lower(argv[0]); + sharename = strlower_talloc(ctx, argv[0]); us_path = argv[1]; us_comment = argv[2]; break; case 4: - sharename = strdup_lower(argv[0]); + sharename = strlower_talloc(ctx, argv[0]); us_path = argv[1]; us_comment = argv[2]; arg_acl = argv[3]; break; case 5: - sharename = strdup_lower(argv[0]); + sharename = strlower_talloc(ctx, argv[0]); us_path = argv[1]; us_comment = argv[2]; arg_acl = argv[3]; diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c index dcdc8e9a40..17801b2a80 100644 --- a/source3/utils/ntlm_auth_diagnostics.c +++ b/source3/utils/ntlm_auth_diagnostics.c @@ -458,31 +458,31 @@ static bool test_plaintext(enum ntlm_break break_which) flags |= WBFLAG_PAM_LMKEY; flags |= WBFLAG_PAM_USER_SESSION_KEY; - if (!push_ucs2_allocate(&nt_response_ucs2, opt_password, + if (!push_ucs2_talloc(NULL, &nt_response_ucs2, opt_password, &converted_size)) { - DEBUG(0, ("push_ucs2_allocate failed!\n")); + DEBUG(0, ("push_ucs2_talloc failed!\n")); exit(1); } nt_response.data = (unsigned char *)nt_response_ucs2; nt_response.length = strlen_w(nt_response_ucs2)*sizeof(smb_ucs2_t); - if ((password = strdup_upper(opt_password)) == NULL) { - DEBUG(0, ("strdup_upper failed!\n")); + if ((password = strupper_talloc(NULL, opt_password)) == NULL) { + DEBUG(0, ("strupper_talloc() failed!\n")); exit(1); } - if (!convert_string_allocate(NULL, CH_UNIX, - CH_DOS, password, - strlen(password)+1, - &lm_response.data, - &lm_response.length, True)) { - DEBUG(0, ("convert_string_allocate failed!\n")); + if (!convert_string_talloc(NULL, CH_UNIX, + CH_DOS, password, + strlen(password)+1, + &lm_response.data, + &lm_response.length, True)) { + DEBUG(0, ("convert_string_talloc failed!\n")); exit(1); } - SAFE_FREE(password); + TALLOC_FREE(password); switch (break_which) { case BREAK_NONE: @@ -513,8 +513,8 @@ static bool test_plaintext(enum ntlm_break break_which) user_session_key, &error_string, NULL); - SAFE_FREE(nt_response.data); - SAFE_FREE(lm_response.data); + TALLOC_FREE(nt_response.data); + TALLOC_FREE(lm_response.data); data_blob_free(&chall); if (!NT_STATUS_IS_OK(nt_status)) { -- cgit