diff options
41 files changed, 190 insertions, 166 deletions
diff --git a/source4/auth/ntlm_check.c b/source4/auth/ntlm_check.c index f1ea6829e0..b98ce50cf6 100644 --- a/source4/auth/ntlm_check.c +++ b/source4/auth/ntlm_check.c @@ -320,7 +320,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx, mdfour(client_nt.hash, nt_response->data, nt_response->length); if (lm_response->length && - (convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, + (convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_DOS, CH_UNIX, lm_response->data, lm_response->length, (void **)&unix_pw) != -1)) { if (E_deshash(unix_pw, client_lm.hash)) { diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c index ea9b52e432..ea80737c80 100644 --- a/source4/auth/ntlmssp/ntlmssp_parse.c +++ b/source4/auth/ntlmssp/ntlmssp_parse.c @@ -64,7 +64,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, case 'U': s = va_arg(ap, char *); head_size += 8; - n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s); + n = push_ucs2_talloc(pointers, global_smb_iconv_convenience, (void **)&pointers[i].data, s); if (n == -1) { return false; } @@ -75,7 +75,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, case 'A': s = va_arg(ap, char *); head_size += 8; - n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s); + n = push_ascii_talloc(pointers, global_smb_iconv_convenience, (char **)&pointers[i].data, s); if (n == -1) { return false; } @@ -87,7 +87,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, n = va_arg(ap, int); intargs[i] = n; s = va_arg(ap, char *); - n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s); + n = push_ucs2_talloc(pointers, global_smb_iconv_convenience, (void **)&pointers[i].data, s); if (n == -1) { return false; } @@ -236,7 +236,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, return false; if (0 < len1) { - pull_string(p, blob->data + ptr, sizeof(p), + pull_string(global_smb_iconv_convenience, p, blob->data + ptr, sizeof(p), len1, STR_UNICODE|STR_NOALIGN); (*ps) = talloc_strdup(mem_ctx, p); if (!(*ps)) { @@ -266,7 +266,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, return false; if (0 < len1) { - pull_string(p, blob->data + ptr, sizeof(p), + pull_string(global_smb_iconv_convenience, p, blob->data + ptr, sizeof(p), len1, STR_ASCII|STR_NOALIGN); (*ps) = talloc_strdup(mem_ctx, p); if (!(*ps)) { @@ -320,7 +320,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data) return false; - head_ofs += pull_string(p, blob->data+head_ofs, sizeof(p), + head_ofs += pull_string(global_smb_iconv_convenience, p, blob->data+head_ofs, sizeof(p), blob->length - head_ofs, STR_ASCII|STR_TERMINATE); if (strcmp(s, p) != 0) { diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index c592bf8de0..278f18cf0d 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -619,7 +619,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb } \ if (_a && _a->value_ctr.num_values >= 1) { \ ssize_t _ret; \ - _ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, \ + _ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, \ _a->value_ctr.values[0].blob->data, \ _a->value_ctr.values[0].blob->length, \ (void **)discard_const(&(p)->elem)); \ diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index dd2da4f0f7..749064d5cf 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -766,7 +766,7 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(const struct dsdb_schema *schem return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, CH_UTF16, CH_UNIX, + ret = convert_string_talloc(out->values, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data, in->value_ctr.values[i].blob->length, (void **)&str); @@ -808,7 +808,7 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(const struct dsdb_schema *schem out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc(blobs, CH_UNIX, CH_UTF16, + ret = convert_string_talloc(blobs, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, (void **)&blobs[i].data); @@ -1043,7 +1043,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(const struct dsdb_ return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, CH_UTF16, CH_UNIX, + ret = convert_string_talloc(out->values, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data+4, in->value_ctr.values[i].blob->length-4, (void **)&str); @@ -1086,7 +1086,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(const struct dsdb_ out->value_ctr.values[i].blob = &blobs[i]; - ret = convert_string_talloc(blobs, CH_UNIX, CH_UTF16, + ret = convert_string_talloc(blobs, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, (void **)&data); diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c index 59f4bb4067..c8c569b7ed 100644 --- a/source4/kdc/kpasswdd.c +++ b/source4/kdc/kpasswdd.c @@ -62,7 +62,7 @@ static bool kpasswdd_make_error_reply(struct kdc_server *kdc, DEBUG(result_code ? 3 : 10, ("kpasswdd: %s\n", error_string)); - len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string); + len = push_utf8_talloc(mem_ctx, global_smb_iconv_convenience, &error_string_utf8, error_string); if (len == -1) { return false; } diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c index bbc40e3e3b..83bd11563f 100644 --- a/source4/lib/charset/charcnv.c +++ b/source4/lib/charset/charcnv.c @@ -4,6 +4,7 @@ Copyright (C) Igor Vergeichik <iverg@mail.ru> 2001 Copyright (C) Andrew Tridgell 2001 Copyright (C) Simo Sorce 2001 + Copyright (C) Jelmer Vernooij 2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -167,9 +168,10 @@ static smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic, * @param destlen maximal length allowed for string * @returns the number of bytes occupied in the destination **/ -_PUBLIC_ ssize_t convert_string(charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen) +_PUBLIC_ ssize_t convert_string(struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen) { size_t i_len, o_len; size_t retval; @@ -180,7 +182,7 @@ _PUBLIC_ ssize_t convert_string(charset_t from, charset_t to, if (srclen == (size_t)-1) srclen = strlen(inbuf)+1; - descriptor = get_conv_handle(global_smb_iconv_convenience, from, to); + descriptor = get_conv_handle(ic, from, to); if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) { /* conversion not supported, use as is */ @@ -202,12 +204,12 @@ _PUBLIC_ ssize_t convert_string(charset_t from, charset_t to, reason="No more room"; if (from == CH_UNIX) { DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n", - charset_name(global_smb_iconv_convenience, from), charset_name(global_smb_iconv_convenience, to), + charset_name(ic, from), charset_name(ic, to), (int)srclen, (int)destlen, (const char *)src)); } else { DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n", - charset_name(global_smb_iconv_convenience, from), charset_name(global_smb_iconv_convenience, to), + charset_name(ic, from), charset_name(ic, to), (int)srclen, (int)destlen)); } return -1; @@ -288,8 +290,11 @@ convert: * @returns Size in bytes of the converted string; or -1 in case of error. **/ -_PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to, - void const *src, size_t srclen, void **dest) +_PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, + struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void **dest) { smb_iconv_t descriptor; @@ -298,13 +303,13 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_ if (src == NULL || srclen == (size_t)-1 || srclen == 0) return (size_t)-1; - descriptor = get_conv_handle(global_smb_iconv_convenience, from, to); + descriptor = get_conv_handle(ic, from, to); if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) { /* conversion not supported, return -1*/ DEBUG(3, ("convert_string_talloc: conversion from %s to %s not supported!\n", - charset_name(global_smb_iconv_convenience, from), - charset_name(global_smb_iconv_convenience, to))); + charset_name(ic, from), + charset_name(ic, to))); return -1; } @@ -325,7 +330,8 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_ * @param dest_len the maximum length in bytes allowed in the * destination. If @p dest_len is -1 then no maximum is used. **/ -static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flags) +static ssize_t push_ascii(struct smb_iconv_convenience *ic, + void *dest, const char *src, size_t dest_len, int flags) { size_t src_len; ssize_t ret; @@ -335,7 +341,7 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag if (tmpbuf == NULL) { return -1; } - ret = push_ascii(dest, tmpbuf, dest_len, flags & ~STR_UPPER); + ret = push_ascii(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER); talloc_free(tmpbuf); return ret; } @@ -345,7 +351,7 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) src_len++; - return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len); + return convert_string(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len); } /** @@ -357,11 +363,11 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag * @returns The number of bytes occupied by the string in the destination * or -1 in case of error. **/ -_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src) +_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src) { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest); + return convert_string_talloc(ctx, ic, CH_UNIX, CH_DOS, src, src_len, (void **)dest); } @@ -380,7 +386,7 @@ _PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src * @param src_len is the length of the source area in bytes. * @returns the number of bytes occupied by the string in @p src. **/ -static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) +static ssize_t pull_ascii(struct smb_iconv_convenience *ic, char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { size_t ret; @@ -395,7 +401,7 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s } } - ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len); + ret = convert_string(ic, CH_DOS, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -419,7 +425,8 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s * @param dest_len is the maximum length allowed in the * destination. If dest_len is -1 then no maxiumum is used. **/ -static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags) +static ssize_t push_ucs2(struct smb_iconv_convenience *ic, + void *dest, const char *src, size_t dest_len, int flags) { size_t len=0; size_t src_len = strlen(src); @@ -430,7 +437,7 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags if (tmpbuf == NULL) { return -1; } - ret = push_ucs2(dest, tmpbuf, dest_len, flags & ~STR_UPPER); + ret = push_ucs2(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER); talloc_free(tmpbuf); return ret; } @@ -448,7 +455,7 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags /* ucs2 is always a multiple of 2 bytes */ dest_len &= ~1; - ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len); + ret = convert_string(ic, CH_UNIX, CH_UTF16, src, src_len, dest, dest_len); if (ret == (size_t)-1) { return 0; } @@ -468,11 +475,11 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags * @returns The number of bytes occupied by the string in the destination * or -1 in case of error. **/ -_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) +_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, void **dest, const char *src) { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, dest); + return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF16, src, src_len, dest); } @@ -484,11 +491,11 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) * @returns The number of bytes occupied by the string in the destination **/ -_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) +_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src) { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest); + return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF8, src, src_len, (void **)dest); } /** @@ -502,7 +509,7 @@ _PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) The resulting string in "dest" is always null terminated. **/ -static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) +static size_t pull_ucs2(struct smb_iconv_convenience *ic, char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { size_t ret; @@ -524,7 +531,7 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src if (src_len != (size_t)-1) src_len &= ~1; - ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len); + ret = convert_string(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -539,11 +546,11 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src * @returns The number of bytes occupied by the string in the destination **/ -_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src) +_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src) { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, ic, CH_DOS, CH_UNIX, src, src_len, (void **)dest); } /** @@ -554,11 +561,11 @@ _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src * @returns The number of bytes occupied by the string in the destination **/ -_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src) +_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const void *src) { size_t src_len = utf16_len(src); *dest = NULL; - return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, ic, CH_UTF16, CH_UNIX, src, src_len, (void **)dest); } /** @@ -569,11 +576,11 @@ _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src) * @returns The number of bytes occupied by the string in the destination **/ -_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) +_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src) { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, ic, CH_UTF8, CH_UNIX, src, src_len, (void **)dest); } /** @@ -590,12 +597,13 @@ _PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) is -1 then no maxiumum is used. **/ -_PUBLIC_ ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags) +_PUBLIC_ ssize_t push_string(struct smb_iconv_convenience *ic, + void *dest, const char *src, size_t dest_len, int flags) { if (flags & STR_ASCII) { - return push_ascii(dest, src, dest_len, flags); + return push_ascii(ic, dest, src, dest_len, flags); } else if (flags & STR_UNICODE) { - return push_ucs2(dest, src, dest_len, flags); + return push_ucs2(ic, dest, src, dest_len, flags); } else { smb_panic("push_string requires either STR_ASCII or STR_UNICODE flag to be set"); return -1; @@ -617,12 +625,13 @@ _PUBLIC_ ssize_t push_string(void *dest, const char *src, size_t dest_len, int f The resulting string in "dest" is always null terminated. **/ -_PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) +_PUBLIC_ ssize_t pull_string(struct smb_iconv_convenience *ic, + char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { if (flags & STR_ASCII) { - return pull_ascii(dest, src, dest_len, src_len, flags); + return pull_ascii(ic, dest, src, dest_len, src_len, flags); } else if (flags & STR_UNICODE) { - return pull_ucs2(dest, src, dest_len, src_len, flags); + return pull_ucs2(ic, dest, src, dest_len, src_len, flags); } else { smb_panic("pull_string requires either STR_ASCII or STR_UNICODE flag to be set"); return -1; @@ -639,7 +648,8 @@ _PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_ return INVALID_CODEPOINT if the next character cannot be converted */ -_PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size) +_PUBLIC_ codepoint_t next_codepoint(struct smb_iconv_convenience *ic, + const char *str, size_t *size) { /* it cannot occupy more than 4 bytes in UTF16 format */ uint8_t buf[4]; @@ -660,7 +670,7 @@ _PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size) ilen_orig = strnlen(str, 5); ilen = ilen_orig; - descriptor = get_conv_handle(global_smb_iconv_convenience, CH_UNIX, CH_UTF16); + descriptor = get_conv_handle(ic, CH_UNIX, CH_UTF16); if (descriptor == (smb_iconv_t)-1) { *size = 1; return INVALID_CODEPOINT; @@ -711,7 +721,8 @@ _PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size) return the number of bytes occupied by the CH_UNIX character, or -1 on failure */ -_PUBLIC_ ssize_t push_codepoint(char *str, codepoint_t c) +_PUBLIC_ ssize_t push_codepoint(struct smb_iconv_convenience *ic, + char *str, codepoint_t c) { smb_iconv_t descriptor; uint8_t buf[4]; @@ -723,7 +734,7 @@ _PUBLIC_ ssize_t push_codepoint(char *str, codepoint_t c) return 1; } - descriptor = get_conv_handle(global_smb_iconv_convenience, + descriptor = get_conv_handle(ic, CH_UTF16, CH_UNIX); if (descriptor == (smb_iconv_t)-1) { return -1; diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 96762af85a..b1bb18a7c8 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -71,6 +71,8 @@ typedef struct smb_iconv_s { #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */ struct loadparm_context; +struct smb_iconv_convenience; +extern struct smb_iconv_convenience *global_smb_iconv_convenience; #include "lib/charset/charset_proto.h" diff --git a/source4/lib/charset/tests/iconv.c b/source4/lib/charset/tests/iconv.c index bc5ae62dae..ca13dc503a 100644 --- a/source4/lib/charset/tests/iconv.c +++ b/source4/lib/charset/tests/iconv.c @@ -288,7 +288,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) size_t size, size2; codepoint_t c; - size = push_codepoint((char *)buf, codepoint); + size = push_codepoint(global_smb_iconv_convenience, (char *)buf, codepoint); torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000), "Invalid Codepoint range"); @@ -299,7 +299,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) buf[size+2] = random(); buf[size+3] = random(); - c = next_codepoint((char *)buf, &size2); + c = next_codepoint(global_smb_iconv_convenience, (char *)buf, &size2); torture_assert(tctx, c == codepoint, talloc_asprintf(tctx, diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c index e9cca090cc..67a790c250 100644 --- a/source4/lib/charset/util_unistr.c +++ b/source4/lib/charset/util_unistr.c @@ -129,8 +129,8 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2) if (s2 == NULL) return 1; while (*s1 && *s2) { - c1 = next_codepoint(s1, &size1); - c2 = next_codepoint(s2, &size2); + c1 = next_codepoint(global_smb_iconv_convenience, s1, &size1); + c2 = next_codepoint(global_smb_iconv_convenience, s2, &size2); s1 += size1; s2 += size2; @@ -215,8 +215,8 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n) while (*s1 && *s2 && n) { n--; - c1 = next_codepoint(s1, &size1); - c2 = next_codepoint(s2, &size2); + c1 = next_codepoint(global_smb_iconv_convenience, s1, &size1); + c2 = next_codepoint(global_smb_iconv_convenience, s2, &size2); s1 += size1; s2 += size2; @@ -275,7 +275,7 @@ _PUBLIC_ void string_replace_w(char *s, char oldc, char newc) { while (s && *s) { size_t size; - codepoint_t c = next_codepoint(s, &size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &size); if (c == oldc) { *s = newc; } @@ -353,7 +353,7 @@ _PUBLIC_ size_t strlen_m(const char *s) while (*s) { size_t c_size; - codepoint_t c = next_codepoint(s, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size); if (c < 0x10000) { count += 1; } else { @@ -391,7 +391,7 @@ _PUBLIC_ char *strchr_m(const char *s, char c) while (*s) { size_t size; - codepoint_t c2 = next_codepoint(s, &size); + codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size); if (c2 == c) { return discard_const_p(char, s); } @@ -416,7 +416,7 @@ _PUBLIC_ char *strrchr_m(const char *s, char c) while (*s) { size_t size; - codepoint_t c2 = next_codepoint(s, &size); + codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size); if (c2 == c) { ret = discard_const_p(char, s); } @@ -436,7 +436,7 @@ _PUBLIC_ bool strhaslower(const char *string) codepoint_t s; codepoint_t t; - s = next_codepoint(string, &c_size); + s = next_codepoint(global_smb_iconv_convenience, string, &c_size); string += c_size; t = toupper_w(s); @@ -459,7 +459,7 @@ _PUBLIC_ bool strhasupper(const char *string) codepoint_t s; codepoint_t t; - s = next_codepoint(string, &c_size); + s = next_codepoint(global_smb_iconv_convenience, string, &c_size); string += c_size; t = tolower_w(s); @@ -489,12 +489,12 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src) while (*src) { size_t c_size; - codepoint_t c = next_codepoint(src, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, src, &c_size); src += c_size; c = tolower_w(c); - c_size = push_codepoint(dest+size, c); + c_size = push_codepoint(global_smb_iconv_convenience, dest+size, c); if (c_size == -1) { talloc_free(dest); return NULL; @@ -533,12 +533,12 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) while (*src) { size_t c_size; - codepoint_t c = next_codepoint(src, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, src, &c_size); src += c_size; c = toupper_w(c); - c_size = push_codepoint(dest+size, c); + c_size = push_codepoint(global_smb_iconv_convenience, dest+size, c); if (c_size == -1) { talloc_free(dest); return NULL; @@ -579,8 +579,8 @@ _PUBLIC_ void strlower_m(char *s) while (*s) { size_t c_size, c_size2; - codepoint_t c = next_codepoint(s, &c_size); - c_size2 = push_codepoint(d, tolower_w(c)); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size); + c_size2 = push_codepoint(global_smb_iconv_convenience, d, tolower_w(c)); if (c_size2 > c_size) { DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n", c, tolower_w(c), (int)c_size, (int)c_size2)); @@ -615,8 +615,8 @@ _PUBLIC_ void strupper_m(char *s) while (*s) { size_t c_size, c_size2; - codepoint_t c = next_codepoint(s, &c_size); - c_size2 = push_codepoint(d, toupper_w(c)); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size); + c_size2 = push_codepoint(global_smb_iconv_convenience, d, toupper_w(c)); if (c_size2 > c_size) { DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n", c, toupper_w(c), (int)c_size, (int)c_size2)); @@ -638,7 +638,7 @@ _PUBLIC_ size_t count_chars_w(const char *s, char c) while (*s) { size_t size; - codepoint_t c2 = next_codepoint(s, &size); + codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size); if (c2 == c) count++; s += size; } diff --git a/source4/lib/policy/lex.c b/source4/lib/policy/lex.c index fd4c102142..5364706fc4 100644 --- a/source4/lib/policy/lex.c +++ b/source4/lib/policy/lex.c @@ -600,7 +600,7 @@ static bool utf16 = false; if (fread(&v, 2, 1, yyin) < 1) \ result = YY_NULL; \ else \ - result = push_codepoint(buf, v); \ + result = push_codepoint(global_smb_iconv_convenience, buf, v); \ } else { \ int c = getc(yyin); \ result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 6ce422049b..0e556da9e2 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -54,7 +54,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, + data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF8, CH_UTF16, val->data, val->length, (void **)&data->data); break; @@ -85,7 +85,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, switch (type) { case REG_SZ: case REG_EXPAND_SZ: - val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + val.length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, (void *)data.data, data.length, (void **)&val.data); diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 90a4f2529a..6af239fc21 100644 --- a/source4/lib/registry/patchfile_preg.c +++ b/source4/lib/registry/patchfile_preg.c @@ -36,7 +36,7 @@ static WERROR preg_read_utf16(int fd, char *c) if (read(fd, &v, 2) < 2) { return WERR_GENERAL_FAILURE; } - push_codepoint(c, v); + push_codepoint(global_smb_iconv_convenience, c, v); return WERR_OK; } diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 13e27cd80b..1acb6342e7 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -52,7 +52,7 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx) static bool test_reg_val_data_string_sz(struct torture_context *ctx) { DATA_BLOB db; - db.length = convert_string_talloc(ctx, CH_UNIX, CH_UTF16, + db.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, "bla", 3, (void **)&db.data); torture_assert_str_equal(ctx, "bla", reg_val_data_string(ctx, REG_SZ, db), @@ -87,7 +87,7 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx) static bool test_reg_val_description(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc(ctx, CH_UNIX, CH_UTF16, + data.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, "stationary traveller", strlen("stationary traveller"), (void **)&data.data); @@ -101,7 +101,7 @@ static bool test_reg_val_description(struct torture_context *ctx) static bool test_reg_val_description_nullname(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc(ctx, CH_UNIX, CH_UTF16, + data.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, "west berlin", strlen("west berlin"), (void **)&data.data); diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index ca3e3dd619..f75fc835b5 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -61,7 +61,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, switch (type) { case REG_EXPAND_SZ: case REG_SZ: - convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, data.data, data.length, (void **)&ret); return ret; @@ -117,7 +117,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, + data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&data->data); break; diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c index 8037c6de0a..0757a02e47 100644 --- a/source4/lib/tdr/tdr.c +++ b/source4/lib/tdr/tdr.c @@ -153,7 +153,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, TDR_PULL_NEED_BYTES(tdr, el_size*length); - ret = convert_string_talloc(ctx, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v)); + ret = convert_string_talloc(ctx, global_smb_iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v)); if (ret == -1) { return NT_STATUS_INVALID_PARAMETER; @@ -175,7 +175,7 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, required = el_size * length; TDR_PUSH_NEED_BYTES(tdr, required); - ret = convert_string(CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required); + ret = convert_string(global_smb_iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required); if (ret == -1) { return NT_STATUS_INVALID_PARAMETER; diff --git a/source4/lib/util/dprintf.c b/source4/lib/util/dprintf.c index be716241e3..5b3fe4b1ea 100644 --- a/source4/lib/util/dprintf.c +++ b/source4/lib/util/dprintf.c @@ -55,7 +55,7 @@ again: SAFE_FREE(p); return -1; } - clen = convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen); + clen = convert_string(global_smb_iconv_convenience, CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen); if (clen == -1) { /* the string can't be converted - do the best we can, filling in non-printing chars with '?' */ diff --git a/source4/lib/util/ms_fnmatch.c b/source4/lib/util/ms_fnmatch.c index 73fb0e0966..e1bf6f94c5 100644 --- a/source4/lib/util/ms_fnmatch.c +++ b/source4/lib/util/ms_fnmatch.c @@ -64,7 +64,7 @@ static int ms_fnmatch_core(const char *p, const char *n, int i; size_t size, size_n; - while ((c = next_codepoint(p, &size))) { + while ((c = next_codepoint(global_smb_iconv_convenience, p, &size))) { p += size; switch (c) { @@ -74,7 +74,7 @@ static int ms_fnmatch_core(const char *p, const char *n, return null_match(p); } for (i=0; n[i]; i += size_n) { - next_codepoint(n+i, &size_n); + next_codepoint(global_smb_iconv_convenience, n+i, &size_n); if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) { return 0; } @@ -93,7 +93,7 @@ static int ms_fnmatch_core(const char *p, const char *n, return -1; } for (i=0; n[i]; i += size_n) { - next_codepoint(n+i, &size_n); + next_codepoint(global_smb_iconv_convenience, n+i, &size_n); if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0; if (n+i == ldot) { if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0; @@ -109,7 +109,7 @@ static int ms_fnmatch_core(const char *p, const char *n, if (! *n) { return -1; } - next_codepoint(n, &size_n); + next_codepoint(global_smb_iconv_convenience, n, &size_n); n += size_n; break; @@ -123,7 +123,7 @@ static int ms_fnmatch_core(const char *p, const char *n, break; } if (! *n) return null_match(p); - next_codepoint(n, &size_n); + next_codepoint(global_smb_iconv_convenience, n, &size_n); n += size_n; break; @@ -133,12 +133,12 @@ static int ms_fnmatch_core(const char *p, const char *n, return 0; } if (*n != '.') return -1; - next_codepoint(n, &size_n); + next_codepoint(global_smb_iconv_convenience, n, &size_n); n += size_n; break; default: - c2 = next_codepoint(n, &size_n); + c2 = next_codepoint(global_smb_iconv_convenience, n, &size_n); if (c != c2 && codepoint_cmpi(c, c2) != 0) { return -1; } diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index bfac395ef9..ccad1058bf 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -67,7 +67,7 @@ _PUBLIC_ bool E_md4hash(const char *passwd, uint8_t p16[16]) int len; void *wpwd; - len = push_ucs2_talloc(NULL, &wpwd, passwd); + len = push_ucs2_talloc(NULL, global_smb_iconv_convenience, &wpwd, passwd); if (len < 2) { /* We don't want to return fixed data, as most callers * don't check */ @@ -97,7 +97,7 @@ _PUBLIC_ bool E_deshash(const char *passwd, uint8_t p16[16]) ZERO_STRUCT(dospwd); /* Password must be converted to DOS charset - null terminated, uppercase. */ - push_string(dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE); + push_string(global_smb_iconv_convenience, dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE); /* Only the fisrt 14 chars are considered, password need not be null terminated. */ E_P16((const uint8_t *)dospwd, p16); @@ -150,14 +150,14 @@ bool ntv2_owf_gen(const uint8_t owf[16], } } - user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in); + user_byte_len = push_ucs2_talloc(mem_ctx, global_smb_iconv_convenience, &user, user_in); if (user_byte_len == (ssize_t)-1) { DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); return false; } - domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in); + domain_byte_len = push_ucs2_talloc(mem_ctx, global_smb_iconv_convenience, &domain, domain_in); if (domain_byte_len == (ssize_t)-1) { DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n")); talloc_free(mem_ctx); @@ -468,7 +468,7 @@ bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag /* the incoming buffer can be any alignment. */ string_flags |= STR_NOALIGN; - new_pw_len = push_string(new_pw, + new_pw_len = push_string(global_smb_iconv_convenience, new_pw, password, sizeof(new_pw), string_flags); @@ -521,7 +521,7 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, } /* decode into the return buffer. Buffer length supplied */ - *new_pw_len = pull_string(new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, + *new_pw_len = pull_string(global_smb_iconv_convenience, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, byte_len, string_flags); #ifdef DEBUG_PASSWORD diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index 17e1792fe3..972ae7f5e1 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -61,7 +61,9 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx, if (nlen > blob.length - (ofs + 24)) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - size = convert_string_talloc(io->streams, CH_UTF16, CH_UNIX, + size = convert_string_talloc(io->streams, + global_smb_iconv_convenience, + CH_UTF16, CH_UNIX, blob.data+ofs+24, nlen, &vstr); if (size == -1) { return NT_STATUS_ILLEGAL_CHARACTER; diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index 6a4f432088..43c984721b 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -418,7 +418,7 @@ size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, uin smbcli_req_grow_allocation(req, len + req->out.data_size); - len = push_string(req->out.data + req->out.data_size, str, len, flags); + len = push_string(global_smb_iconv_convenience, req->out.data + req->out.data_size, str, len, flags); smbcli_req_grow_data(req, len + req->out.data_size); @@ -574,7 +574,7 @@ static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_c return 0; } - ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest); + ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest); if (ret == -1) { *dest = NULL; return 0; @@ -616,7 +616,7 @@ size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx, src_len2++; } - ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest); + ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)dest); if (ret == -1) { *dest = NULL; @@ -626,7 +626,7 @@ size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx, return ret; } -/* +/** pull a string from a request packet, returning a talloced string the string length is limited by the 3 things: @@ -651,7 +651,7 @@ size_t smbcli_req_pull_string(struct smbcli_request *req, TALLOC_CTX *mem_ctx, } -/* +/** pull a DATA_BLOB from a reply packet, returning a talloced blob make sure we don't go past end of packet @@ -723,7 +723,7 @@ NTTIME smbcli_pull_nttime(void *base, uint16_t offset) return ret; } -/* +/** pull a UCS2 string from a blob, returning a talloced unix string the string length is limited by the 3 things: @@ -769,7 +769,7 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, src_len2 = utf16_len_n(src, src_len); - ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; return 0; @@ -779,7 +779,7 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, return src_len2 + alignment; } -/* +/** pull a ascii string from a blob, returning a talloced string the string length is limited by the 3 things: @@ -815,7 +815,7 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, src_len2++; } - ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; @@ -826,7 +826,7 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, return ret; } -/* +/** pull a string from a blob, returning a talloced struct smb_wire_string the string length is limited by the 3 things: @@ -895,7 +895,7 @@ size_t smbcli_blob_pull_string(struct smbcli_session *session, blob->data+str_offset, dest->private_length, flags); } -/* +/** pull a string from a blob, returning a talloced char * Currently only used by the UNIX search info level. @@ -965,7 +965,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session, return 0; } - len = push_string(blob->data + blob->length, str, max_len, flags); + len = push_string(global_smb_iconv_convenience, blob->data + blob->length, str, max_len, flags); blob->length += len; diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index 576e2b6fcf..5a7534f906 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -579,7 +579,7 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me return NT_STATUS_OK; } - size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + size = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, blob.data, blob.length, &vstr); data_blob_free(&blob); (*str) = (char *)vstr; @@ -604,7 +604,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf, return smb2_push_o16s16_blob(buf, ofs, data_blob(NULL, 0)); } - size = convert_string_talloc(buf->buffer, CH_UNIX, CH_UTF16, + size = convert_string_talloc(buf->buffer, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, str, strlen(str), (void **)&blob.data); if (size == -1) { return NT_STATUS_ILLEGAL_CHARACTER; diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index 5c7266d7a8..2186271491 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -185,7 +185,7 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, if (strcasecmp_m(s->name, secret_name) != 0) { continue; } - if (convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + if (convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, s->secret.data, s->secret.length, (void **)&secret_string) == -1) { r->out.error_string = talloc_asprintf(mem_ctx, diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index a15855493c..7e84211e87 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -82,7 +82,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - chset, CH_UNIX, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len2 + c_len_term)*byte_mul, (void **)&as); @@ -119,6 +119,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, @@ -157,6 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, @@ -191,6 +193,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len3 + c_len_term)*byte_mul, @@ -223,6 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len3, @@ -243,7 +247,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } ret = convert_string_talloc(ndr->current_mem_ctx, - chset, CH_UNIX, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, (void **)&as); @@ -260,6 +264,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1*byte_mul, @@ -285,6 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, + global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, @@ -349,7 +355,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, LIBNDR_FLAG_STR_FIXLEN32))) { s_len++; } - d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, (void **)&dest); + d_len = convert_string_talloc(ndr, global_smb_iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest); if (d_len == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); @@ -683,7 +689,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, NDR_PULL_NEED_BYTES(ndr, length*byte_mul); - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc(ndr->current_mem_ctx, global_smb_iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, length*byte_mul, @@ -708,7 +714,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, required = byte_mul * length; NDR_PUSH_NEED_BYTES(ndr, required); - ret = convert_string(CH_UNIX, chset, + ret = convert_string(global_smb_iconv_convenience, CH_UNIX, chset, var, strlen(var), ndr->data+ndr->offset, required); if (ret == -1) { diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index 3aa63bd2ca..5c351b2df2 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -107,16 +107,16 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, while (*p2) { codepoint_t c1, c2; size_t c_size1, c_size2; - c1 = next_codepoint(p1, &c_size1); - c2 = next_codepoint(p2, &c_size2); + c1 = next_codepoint(global_smb_iconv_convenience, p1, &c_size1); + c2 = next_codepoint(global_smb_iconv_convenience, p2, &c_size2); if (c2 == '?') { - d += push_codepoint(d, c1); + d += push_codepoint(global_smb_iconv_convenience, d, c1); } else if (c2 == '*') { memcpy(d, p1, strlen(p1)); d += strlen(p1); break; } else { - d += push_codepoint(d, c2); + d += push_codepoint(global_smb_iconv_convenience, d, c2); } p1 += c_size1; diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 8a7aa13351..f1d701b343 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -256,7 +256,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name, while (*p) { size_t c_size; - codepoint_t c = next_codepoint(p, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, p, &c_size); switch (c) { case '\\': if (name->has_wildcard) { @@ -340,7 +340,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t if (s == NULL) return NT_STATUS_NO_MEMORY; for (num_components=1, p=s; *p; p += c_size) { - c = next_codepoint(p, &c_size); + c = next_codepoint(global_smb_iconv_convenience, p, &c_size); if (c == '\\') num_components++; } @@ -352,7 +352,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t components[0] = s; for (i=0, p=s; *p; p += c_size) { - c = next_codepoint(p, &c_size); + c = next_codepoint(global_smb_iconv_convenience, p, &c_size); if (c == '\\') { *p = 0; components[++i] = p+1; diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c index 1cbe287a4b..e671804ca6 100644 --- a/source4/ntvfs/posix/pvfs_shortname.c +++ b/source4/ntvfs/posix/pvfs_shortname.c @@ -388,7 +388,7 @@ static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name) { while (*name) { size_t c_size; - codepoint_t c = next_codepoint(name, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, name, &c_size); if (c == INVALID_CODEPOINT) { return false; } diff --git a/source4/ntvfs/posix/pvfs_util.c b/source4/ntvfs/posix/pvfs_util.c index fd9724f7e2..b7cba00d9b 100644 --- a/source4/ntvfs/posix/pvfs_util.c +++ b/source4/ntvfs/posix/pvfs_util.c @@ -181,7 +181,7 @@ uint32_t pvfs_name_hash(const char *key, size_t length) while (*key && length--) { size_t c_size; - codepoint_t c = next_codepoint(key, &c_size); + codepoint_t c = next_codepoint(global_smb_iconv_convenience, key, &c_size); c = toupper_w(c); value *= fnv1_prime; value ^= (uint32_t)c; diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c index f9d3235116..baa1d876d6 100644 --- a/source4/ntvfs/print/vfs_print.c +++ b/source4/ntvfs/print/vfs_print.c @@ -83,8 +83,8 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs, p = (char *)io->ioctl.out.blob.data; SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */); - push_string(p+2, lp_netbios_name(global_loadparm), 15, STR_TERMINATE|STR_ASCII); - push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII); + push_string(global_smb_iconv_convenience, p+2, lp_netbios_name(global_loadparm), 15, STR_TERMINATE|STR_ASCII); + push_string(global_smb_iconv_convenience, p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII); return NT_STATUS_OK; } diff --git a/source4/param/param.h b/source4/param/param.h index db948d8f11..210b21d9a0 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -64,6 +64,5 @@ struct loadparm_service; extern struct loadparm_context *global_loadparm; extern struct loadparm_service sDefault; -extern struct smb_iconv_convenience *global_smb_iconv_convenience; #endif /* _PARAM_H */ diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c index a98266c3da..d0dd96c087 100644 --- a/source4/scripting/ejs/smbcalls_data.c +++ b/source4/scripting/ejs/smbcalls_data.c @@ -177,7 +177,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv) case REG_EXPAND_SZ: { char *s; ssize_t len; - len = convert_string_talloc(mprMemCtx(), CH_UTF16, CH_UNIX, + len = convert_string_talloc(mprMemCtx(), global_smb_iconv_convenience, CH_UTF16, CH_UNIX, blob->data, blob->length, (void **)&s); if (len == -1) { ejsSetErrorMsg(eid, "regToVar invalid REG_SZ string"); @@ -225,7 +225,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv) if (slen == 2 && b.length == 2 && SVAL(b.data, 0) == 0) { break; } - len = convert_string_talloc(mprMemCtx(), CH_UTF16, CH_UNIX, + len = convert_string_talloc(mprMemCtx(), global_smb_iconv_convenience, CH_UTF16, CH_UNIX, b.data, slen, (void **)&s); if (len == -1) { ejsSetErrorMsg(eid, "regToVar invalid REG_MULTI_SZ string"); diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c index 3683991526..237ebd4d7e 100644 --- a/source4/smb_server/blob.c +++ b/source4/smb_server/blob.c @@ -138,10 +138,10 @@ size_t smbsrv_blob_push_string(TALLOC_CTX *mem_ctx, alignment = 1; if (dest_len > 0) { SCVAL(blob->data + offset, 0, 0); - ret = push_string(blob->data + offset + 1, str, dest_len-1, flags); + ret = push_string(global_smb_iconv_convenience, blob->data + offset + 1, str, dest_len-1, flags); } } else { - ret = push_string(blob->data + offset, str, dest_len, flags); + ret = push_string(global_smb_iconv_convenience, blob->data + offset, str, dest_len, flags); } /* sometimes the string needs to be terminated, but the length diff --git a/source4/smb_server/smb/nttrans.c b/source4/smb_server/smb/nttrans.c index 046f6ca0ec..25cddd6654 100644 --- a/source4/smb_server/smb/nttrans.c +++ b/source4/smb_server/smb/nttrans.c @@ -372,7 +372,7 @@ static NTSTATUS nttrans_notify_change_send(struct nttrans_op *op) ssize_t len; SIVAL(p, 4, info->nttrans.out.changes[i].action); - len = push_string(p + 12, info->nttrans.out.changes[i].name.s, + len = push_string(global_smb_iconv_convenience, p + 12, info->nttrans.out.changes[i].name.s, op->trans->out.params.length - (p+12 - op->trans->out.params.data), STR_UNICODE); SIVAL(p, 8, len); diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index da8d1e2d05..cdeba02dd7 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -408,7 +408,7 @@ size_t req_push_str(struct smbsrv_request *req, uint8_t *dest, const char *str, dest = req->out.buffer + PTR_DIFF(dest, buf0); } - len = push_string(dest, str, len, flags); + len = push_string(global_smb_iconv_convenience, dest, str, len, flags); grow_size = len + PTR_DIFF(dest, req->out.data); @@ -447,7 +447,7 @@ size_t req_append_var_block(struct smbsrv_request *req, req_grow_data(req, byte_len + 3 + req->out.data_size); return byte_len + 3; } -/* +/** pull a UCS2 string from a request packet, returning a talloced unix string the string length is limited by the 3 things: @@ -494,7 +494,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const return src_len2 + alignment; } - ret = convert_string_talloc(req, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(req, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; @@ -505,7 +505,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const return src_len2 + alignment; } -/* +/** pull a ascii string from a request packet, returning a talloced string the string length is limited by the 3 things: @@ -543,7 +543,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons src_len2++; } - ret = convert_string_talloc(req, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(req, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; @@ -554,7 +554,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons return src_len2; } -/* +/** pull a string from a request packet, returning a talloced string the string length is limited by the 3 things: @@ -578,7 +578,7 @@ size_t req_pull_string(struct smbsrv_request *req, const char **dest, const uint } -/* +/** pull a ASCII4 string buffer from a request packet, returning a talloced string an ASCII4 buffer is a null terminated string that has a prefix @@ -611,7 +611,7 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const uint return ret + 1; } -/* +/** pull a DATA_BLOB from a request packet, returning a talloced blob return false if any part is outside the data portion of the packet diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c index 47b5dbe60c..a5fc3d8268 100644 --- a/source4/smb_server/smb2/fileio.c +++ b/source4/smb_server/smb2/fileio.c @@ -352,7 +352,7 @@ static void smb2srv_notify_send(struct ntvfs_request *ntvfs) ssize_t len; SIVAL(p, 4, io->smb2.out.changes[i].action); - len = push_string(p + 12, io->smb2.out.changes[i].name.s, + len = push_string(global_smb_iconv_convenience, p + 12, io->smb2.out.changes[i].name.s, blob.length - (p+12 - blob.data), STR_UNICODE); SIVAL(p, 8, len); diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index b1e3b96c2b..6b993aad8c 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -55,7 +55,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, } SSVAL(ucs_name, i*2, 0); - i = convert_string_talloc(ucs_name, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname); + i = convert_string_talloc(ucs_name, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname); if (i == -1) { torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n"); talloc_free(ucs_name); diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c index f97bb404c0..884be8490d 100644 --- a/source4/torture/basic/scanner.c +++ b/source4/torture/basic/scanner.c @@ -207,7 +207,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(¶m[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); status = try_trans2_len(cli, "fname", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); @@ -218,7 +218,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(¶m[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); @@ -230,7 +230,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level, smbcli_mkdir(cli->tree, "\\testdir"); param_len = 2; SSVAL(param, 0, level); - param_len += push_string(¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE); status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); @@ -439,7 +439,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(¶m[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE); status = try_nttrans_len(cli, "fname", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); @@ -450,7 +450,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(¶m[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE); status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); @@ -462,7 +462,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level, smbcli_mkdir(cli->tree, "\\testdir"); param_len = 2; SSVAL(param, 0, level); - param_len += push_string(¶m[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(global_smb_iconv_convenience, ¶m[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE); status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 82511aa8f9..244378dbc9 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -49,7 +49,7 @@ bool torture_utable(struct torture_context *tctx, SSVAL(c2, 0, c); fstrcpy(fname, "\\utable\\x"); p = fname+strlen(fname); - len = convert_string(CH_UTF16, CH_UNIX, + len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; @@ -108,7 +108,7 @@ static char *form_name(int c) p = fname+strlen(fname); SSVAL(c2, 0, c); - len = convert_string(CH_UTF16, CH_UNIX, + len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index 6c07a2747f..7ef2555800 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -182,7 +182,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr, return NT_STATUS_INVALID_PARAMETER; *dest = talloc_zero_array(mem_ctx, char, len+1); - pull_string(*dest, p, len+1, len, STR_ASCII); + pull_string(global_smb_iconv_convenience, *dest, p, len+1, len, STR_ASCII); return NT_STATUS_OK; } diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index fa54f43afd..184125b493 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -2314,7 +2314,8 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, memcpy(servername, r.out.info.info0.name, 16); servername[16] = '\0'; - if (pull_ascii_talloc(mem_ctx, name, servername) < 0) { + if (pull_ascii_talloc(mem_ctx, global_smb_iconv_convenience, + name, servername) < 0) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 9da43c9392..e7f14a89e2 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -1157,8 +1157,9 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea ZERO_STRUCT(user_session_key); - if ((push_ucs2_talloc(samlogon_state->mem_ctx, &unicodepw, - samlogon_state->password)) == -1) { + if ((push_ucs2_talloc(samlogon_state->mem_ctx, + global_smb_iconv_convenience, + &unicodepw, samlogon_state->password)) == -1) { DEBUG(0, ("push_ucs2_allocate failed!\n")); exit(1); } @@ -1167,9 +1168,10 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password); - if ((convert_string_talloc(samlogon_state->mem_ctx, CH_UNIX, - CH_DOS, password, - strlen(password)+1, + if ((convert_string_talloc(samlogon_state->mem_ctx, + global_smb_iconv_convenience, + CH_UNIX, CH_DOS, + password, strlen(password)+1, (void**)&dospw)) == -1) { DEBUG(0, ("convert_string_talloc failed!\n")); exit(1); diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index dba2fa16e3..ddec59a15d 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -966,7 +966,8 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx, size_t size; uint8_t *msg; - size = push_ucs2_talloc(tctx, (void **)&msg, message); + size = push_ucs2_talloc(tctx, global_smb_iconv_convenience, + (void **)&msg, message); r.in.server_name = dcerpc_server_name(p); r.in.message_name = dcerpc_server_name(p); |