diff options
24 files changed, 109 insertions, 73 deletions
diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c index 91a16a1cda..d63a9ce194 100644 --- a/lib/util/charset/charcnv.c +++ b/lib/util/charset/charcnv.c @@ -164,7 +164,7 @@ 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(struct smb_iconv_convenience *ic, +_PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen) @@ -286,7 +286,7 @@ convert: * @returns Size in bytes of the converted string; or -1 in case of error. **/ -_PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, +_PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index cba8aaf5f3..56fa36faf3 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -113,6 +113,16 @@ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src); ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags); ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags); +ssize_t convert_string_talloc(TALLOC_CTX *ctx, + charset_t from, charset_t to, + void const *src, size_t srclen, + void **dest); + +ssize_t convert_string(charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen); + + /* codepoints */ codepoint_t next_codepoint(struct smb_iconv_convenience *ic, const char *str, size_t *size); @@ -128,12 +138,12 @@ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx, const char *unix_charset, bool native_iconv); -ssize_t convert_string(struct smb_iconv_convenience *ic, +ssize_t convert_string_convenience(struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen); ssize_t convert_string_talloc_descriptor(TALLOC_CTX *ctx, smb_iconv_t descriptor, void const *src, size_t srclen, void **dest); -ssize_t convert_string_talloc(TALLOC_CTX *ctx, +ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 2352b9f532..91d0be109a 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -618,7 +618,6 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag { size_t src_len; ssize_t ret; - struct smb_iconv_convenience *ic = get_iconv_convenience(); if (flags & STR_UPPER) { char *tmpbuf = strupper_talloc(NULL, src); @@ -635,7 +634,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(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len); + return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len); } /** @@ -649,10 +648,9 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag **/ _PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, ic, CH_UNIX, CH_DOS, src, src_len, (void **)dest); + return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest); } @@ -673,7 +671,6 @@ _PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src **/ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t ret; if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) { @@ -687,7 +684,7 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s } } - ret = convert_string(ic, CH_DOS, CH_UNIX, src, src_len, dest, dest_len); + ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -713,7 +710,6 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s **/ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t len=0; size_t src_len = strlen(src); size_t ret; @@ -741,7 +737,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(ic, CH_UNIX, CH_UTF16, src, src_len, dest, dest_len); + ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len); if (ret == (size_t)-1) { return 0; } @@ -763,10 +759,9 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags **/ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF16, src, src_len, dest); + return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, dest); } @@ -780,10 +775,9 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src) _PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF8, src, src_len, (void **)dest); + return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest); } /** @@ -799,7 +793,6 @@ _PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src_len, int flags) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t ret; if (ucs2_align(NULL, src, flags)) { @@ -820,7 +813,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(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len); + ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -837,10 +830,9 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, ic, CH_DOS, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest); } /** @@ -853,10 +845,9 @@ _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = utf16_len(src); *dest = NULL; - return convert_string_talloc(ctx, ic, CH_UTF16, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest); } /** @@ -869,10 +860,9 @@ _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src) _PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src) { - struct smb_iconv_convenience *ic = get_iconv_convenience(); size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, ic, CH_UTF8, CH_UNIX, src, src_len, (void **)dest); + return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest); } /** @@ -929,3 +919,39 @@ _PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_ } +/** + * Convert string from one encoding to another, making error checking etc + * + * @param src pointer to source string (multibyte or singlebyte) + * @param srclen length of the source string in bytes + * @param dest pointer to destination string (multibyte or singlebyte) + * @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) +{ + return convert_string_convenience(get_iconv_convenience(), from, to, + src, srclen, + dest, destlen); +} + +/** + * Convert between character sets, allocating a new buffer using talloc for the result. + * + * @param srclen length of source buffer. + * @param dest always set at least to NULL + * @note -1 is not accepted for srclen. + * + * @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) +{ + return convert_string_talloc_convenience(ctx, get_iconv_convenience(), + from, to, src, srclen, dest); +} diff --git a/source4/auth/ntlm/ntlm_check.c b/source4/auth/ntlm/ntlm_check.c index 62dec84f1d..b43190c5ba 100644 --- a/source4/auth/ntlm/ntlm_check.c +++ b/source4/auth/ntlm/ntlm_check.c @@ -321,7 +321,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, lp_iconv_convenience(lp_ctx), CH_DOS, CH_UNIX, + (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(lp_ctx), 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/dsdb/common/util.c b/source4/dsdb/common/util.c index 6a6f370943..69e456274c 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -1657,7 +1657,7 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, ntNewHash = &local_ntNewHash; /* Only check complexity if we can convert it at all. Assuming unconvertable passwords are 'strong' */ - if (convert_string_talloc(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ctx, "loadparm")), + if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ctx, "loadparm")), CH_UTF16, CH_UNIX, new_password->data, new_password->length, (void **)&new_pass) != -1) { diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 5ed7f1fbad..fc8fb775ee 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -1319,7 +1319,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_utf16_str); if (converted_pw_len == -1) { @@ -1337,7 +1337,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), CH_UTF16, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length, (void **)&cleartext_utf8_str); if (converted_pw_len == -1) { @@ -1363,7 +1363,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) if (io->n.cleartext_utf8) { struct samr_Password *lm_hash; char *cleartext_unix; - converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_unix); if (converted_pw_len != -1) { diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 69d4c2ce80..6561e8ed88 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -1169,7 +1169,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, s->iconv_convenience, CH_UTF16, CH_UNIX, \ + _ret = convert_string_talloc_convenience(mem_ctx, s->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 b0018c8161..6ba123fc18 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -769,7 +769,8 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(const struct dsdb_schema *schem return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, schema->iconv_convenience, + ret = convert_string_talloc_convenience(out->values, + schema->iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data, in->value_ctr.values[i].blob->length, @@ -812,7 +813,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, schema->iconv_convenience, CH_UNIX, CH_UTF16, + ret = convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16, in->values[i].data, in->values[i].length, (void **)&blobs[i].data); @@ -1046,7 +1047,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(const struct dsdb_ return WERR_FOOBAR; } - ret = convert_string_talloc(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, + ret = convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX, in->value_ctr.values[i].blob->data+4, in->value_ctr.values[i].blob->length-4, (void **)&str); @@ -1089,7 +1090,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, schema->iconv_convenience, CH_UNIX, CH_UTF16, + ret = convert_string_talloc_convenience(blobs, schema->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 63b5f2a2e4..f5d92cd3c5 100644 --- a/source4/kdc/kpasswdd.c +++ b/source4/kdc/kpasswdd.c @@ -233,7 +233,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, case KRB5_KPASSWD_VERS_CHANGEPW: { DATA_BLOB password; - pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), CH_UTF8, CH_UTF16, (const char *)input->data, input->length, @@ -281,7 +281,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, reply); } - pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), CH_UTF8, CH_UTF16, (const char *)chpw.newpasswd.data, chpw.newpasswd.length, diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 7d78ba1a8f..bf1ec31f56 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -61,7 +61,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, case REG_SZ: case REG_EXPAND_SZ: if (val != NULL) - data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF8, CH_UTF16, + data->length = convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UTF8, CH_UTF16, val->data, val->length, (void **)&data->data); else { @@ -106,7 +106,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, case REG_SZ: case REG_EXPAND_SZ: if (data.data[0] != '\0') { - val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UTF8, + val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, (void *)data.data, data.length, (void **)&val.data); diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 2b7eb838ba..f1fa5ad0b2 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -53,7 +53,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, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + db.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "bla", 3, (void **)&db.data); torture_assert_str_equal(ctx, "bla", reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db), @@ -88,7 +88,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, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "stationary traveller", strlen("stationary traveller"), (void **)&data.data); @@ -102,7 +102,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, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, + data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, 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 b3b6e49ea5..471c425002 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -64,7 +64,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, switch (type) { case REG_EXPAND_SZ: case REG_SZ: - convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF16, CH_UNIX, + convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UTF16, CH_UNIX, data.data, data.length, (void **)&ret); return ret; @@ -124,7 +124,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, + data->length = convert_string_talloc_convenience(mem_ctx, 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 6c5461a335..fd5f3cac60 100644 --- a/source4/lib/tdr/tdr.c +++ b/source4/lib/tdr/tdr.c @@ -154,7 +154,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, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v)); + ret = convert_string_talloc_convenience(ctx, tdr->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; @@ -176,7 +176,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(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required); + ret = convert_string_convenience(tdr->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/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index 0ea5a93606..c3c5f3614b 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -64,7 +64,6 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx, return NT_STATUS_INFO_LENGTH_MISMATCH; } size = convert_string_talloc(io->streams, - lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, blob.data+ofs+24, nlen, &vstr); if (size == -1) { diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index caef28d7fc..6d2565851c 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -586,7 +586,7 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX * return 0; } - ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)dest); + ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest); if (ret == -1) { *dest = NULL; return 0; @@ -628,7 +628,7 @@ size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ct src_len2++; } - ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)dest); + ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest); if (ret == -1) { *dest = NULL; @@ -781,7 +781,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, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; return 0; @@ -827,7 +827,7 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, src_len2++; } - ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index cc355fc33e..0104d8e097 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -676,7 +676,7 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me return NT_STATUS_OK; } - size = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, blob.data, blob.length, &vstr); data_blob_free(&blob); (*str) = (char *)vstr; @@ -707,7 +707,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf, return smb2_push_o16s16_blob(buf, ofs, blob); } - size = convert_string_talloc(buf->buffer, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16, + size = convert_string_talloc(buf->buffer, 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 1fe07b60dc..e259d4df40 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, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX, + if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), 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 a143284f17..265fa68b48 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -81,7 +81,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len2 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len2 + c_len_term)*byte_mul, @@ -118,7 +118,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len1 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -157,7 +157,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len1 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -192,7 +192,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len3 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -225,7 +225,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len3 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -246,7 +246,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, } else { len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, @@ -271,7 +271,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, if (len1 == 0) { as = talloc_strdup(ndr->current_mem_ctx, ""); } else { - ret = convert_string_talloc(ndr->current_mem_ctx, + ret = convert_string_talloc_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -334,7 +334,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, if (!(flags & LIBNDR_FLAG_STR_NOTERM)) { s_len++; } - d_len = convert_string_talloc(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest); + d_len = convert_string_talloc_convenience(ndr, ndr->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"); @@ -645,7 +645,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_convenience(ndr->current_mem_ctx, ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, @@ -671,7 +671,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(ndr->iconv_convenience, CH_UNIX, chset, + ret = convert_string_convenience(ndr->iconv_convenience, CH_UNIX, chset, var, strlen(var), ndr->data+ndr->offset, required); if (ret == -1) { diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c index 859fd03801..1eb6a4f37c 100644 --- a/source4/rpc_server/samr/samr_password.c +++ b/source4/rpc_server/samr/samr_password.c @@ -251,7 +251,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, return NT_STATUS_WRONG_PASSWORD; } - if (convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_DOS, CH_UNIX, (const char *)new_password.data, new_password.length, @@ -261,7 +261,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, return NT_STATUS_WRONG_PASSWORD; } - unicode_pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + unicode_pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_DOS, CH_UTF16, (const char *)new_password.data, new_password.length, @@ -428,7 +428,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, * this) */ if (lm_pwd && r->in.lm_verifier != NULL) { char *new_pass; - if (convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), CH_UTF16, CH_UNIX, (const char *)new_password.data, new_password.length, diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index 52eb69fe68..2cfd6d4f79 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -514,7 +514,7 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, return src_len2 + alignment; } - ret = convert_string_talloc(bufinfo->mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(bufinfo->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; @@ -563,7 +563,7 @@ static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest, src_len2++; } - ret = convert_string_talloc(bufinfo->mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); + ret = convert_string_talloc(bufinfo->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2); if (ret == -1) { *dest = NULL; diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index a5d534b92b..0ae7f6036b 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -56,7 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, } SSVAL(ucs_name, i*2, 0); - i = convert_string_talloc(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname); + i = convert_string_talloc_convenience(ucs_name, lp_iconv_convenience(tctx->lp_ctx), 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/utable.c b/source4/torture/basic/utable.c index 1b44bfe64c..f0700f73a0 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); strncpy(fname, "\\utable\\x", sizeof(fname)-1); p = fname+strlen(fname); - len = convert_string(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, + len = convert_string_convenience(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; @@ -108,7 +108,7 @@ static char *form_name(struct smb_iconv_convenience *iconv_convenience, int c) p = fname+strlen(fname); SSVAL(c2, 0, c); - len = convert_string(iconv_convenience, CH_UTF16, CH_UNIX, + len = convert_string_convenience(iconv_convenience, CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 01368cccad..fc47a86730 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -1171,7 +1171,7 @@ 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, + if ((convert_string_talloc_convenience(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, CH_UNIX, CH_DOS, password, strlen(password)+1, diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c index 9ce9fb7526..ca61d1dddb 100644 --- a/source4/torture/rpc/spoolss_win.c +++ b/source4/torture/rpc/spoolss_win.c @@ -354,7 +354,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx, torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed"); - convert_string_talloc(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, + convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, epk.out.key_buffer, epk.out.needed, (void**)&ctx->printer_keys); |