summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-24 03:40:09 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-24 03:40:09 +0200
commit922a29992ee38b8e1c851192677b89a2cd59a91a (patch)
tree9ea2826f7fd77b27d16de8be61ca7940fb066bad
parent23b04a31f14dca0a3f9bcd58181f84db4b6092c7 (diff)
downloadsamba-922a29992ee38b8e1c851192677b89a2cd59a91a.tar.gz
samba-922a29992ee38b8e1c851192677b89a2cd59a91a.tar.bz2
samba-922a29992ee38b8e1c851192677b89a2cd59a91a.zip
Remove iconv_convenience parameter from simple string push/pull
functions.
-rw-r--r--lib/util/charset/charcnv.c323
-rw-r--r--lib/util/charset/charset.h33
-rw-r--r--lib/util/charset/util_unistr.c329
-rw-r--r--source4/auth/ntlm/auth_util.c2
-rw-r--r--source4/auth/ntlmssp/ntlmssp_client.c2
-rw-r--r--source4/auth/ntlmssp/ntlmssp_parse.c13
-rw-r--r--source4/auth/ntlmssp/ntlmssp_server.c2
-rw-r--r--source4/auth/ntlmssp/ntlmssp_sign.c2
-rw-r--r--source4/kdc/kpasswdd.c2
-rw-r--r--source4/libcli/auth/smbencrypt.c18
-rw-r--r--source4/libcli/raw/rawrequest.c4
-rw-r--r--source4/libcli/smb_composite/sesssetup.c4
-rw-r--r--source4/nsswitch/wbinfo.c2
-rw-r--r--source4/ntvfs/print/vfs_print.c4
-rw-r--r--source4/smb_server/blob.c4
-rw-r--r--source4/smb_server/smb/nttrans.c2
-rw-r--r--source4/smb_server/smb/request.c2
-rw-r--r--source4/smb_server/smb2/fileio.c2
-rw-r--r--source4/torture/basic/scanner.c21
-rw-r--r--source4/torture/rap/rap.c2
-rw-r--r--source4/torture/rpc/netlogon.c2
-rw-r--r--source4/torture/rpc/samba3rpc.c5
-rw-r--r--source4/torture/rpc/samlogon.c5
-rw-r--r--source4/torture/rpc/schannel.c4
-rw-r--r--source4/torture/rpc/wkssvc.c3
-rw-r--r--source4/winbind/wb_pam_auth.c1
26 files changed, 392 insertions, 401 deletions
diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c
index 35119e5395..91a16a1cda 100644
--- a/lib/util/charset/charcnv.c
+++ b/lib/util/charset/charcnv.c
@@ -312,329 +312,6 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
return convert_string_talloc_descriptor(ctx, descriptor, src, srclen, dest);
}
-/**
- * Copy a string from a char* unix src to a dos codepage string destination.
- *
- * @return the number of bytes occupied by the string in the destination.
- *
- * @param flags can include
- * <dl>
- * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
- * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
- * </dl>
- *
- * @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(struct smb_iconv_convenience *ic,
- void *dest, const char *src, size_t dest_len, int flags)
-{
- size_t src_len;
- ssize_t ret;
-
- if (flags & STR_UPPER) {
- char *tmpbuf = strupper_talloc(NULL, src);
- if (tmpbuf == NULL) {
- return -1;
- }
- ret = push_ascii(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER);
- talloc_free(tmpbuf);
- return ret;
- }
-
- src_len = strlen(src);
-
- if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
- src_len++;
-
- return convert_string(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len);
-}
-
-/**
- * Copy a string from a unix char* src to an ASCII destination,
- * allocating a buffer using talloc().
- *
- * @param dest always set at least to NULL
- *
- * @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, struct smb_iconv_convenience *ic, char **dest, const char *src)
-{
- size_t src_len = strlen(src)+1;
- *dest = NULL;
- return convert_string_talloc(ctx, ic, CH_UNIX, CH_DOS, src, src_len, (void **)dest);
-}
-
-
-/**
- * Copy a string from a dos codepage source to a unix char* destination.
- *
- * The resulting string in "dest" is always null terminated.
- *
- * @param flags can have:
- * <dl>
- * <dt>STR_TERMINATE</dt>
- * <dd>STR_TERMINATE means the string in @p src
- * is null terminated, and src_len is ignored.</dd>
- * </dl>
- *
- * @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(struct smb_iconv_convenience *ic, char *dest, const void *src, size_t dest_len, size_t src_len, int flags)
-{
- size_t ret;
-
- if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) {
- if (src_len == (size_t)-1) {
- src_len = strlen((const char *)src) + 1;
- } else {
- size_t len = strnlen((const char *)src, src_len);
- if (len < src_len)
- len++;
- src_len = 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;
-
- return src_len;
-}
-
-/**
- * Copy a string from a char* src to a unicode destination.
- *
- * @returns the number of bytes occupied by the string in the destination.
- *
- * @param flags can have:
- *
- * <dl>
- * <dt>STR_TERMINATE <dd>means include the null termination.
- * <dt>STR_UPPER <dd>means uppercase in the destination.
- * <dt>STR_NOALIGN <dd>means don't do alignment.
- * </dl>
- *
- * @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(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);
- size_t ret;
-
- if (flags & STR_UPPER) {
- char *tmpbuf = strupper_talloc(NULL, src);
- if (tmpbuf == NULL) {
- return -1;
- }
- ret = push_ucs2(ic, dest, tmpbuf, dest_len, flags & ~STR_UPPER);
- talloc_free(tmpbuf);
- return ret;
- }
-
- if (flags & STR_TERMINATE)
- src_len++;
-
- if (ucs2_align(NULL, dest, flags)) {
- *(char *)dest = 0;
- dest = (void *)((char *)dest + 1);
- if (dest_len) dest_len--;
- len++;
- }
-
- /* 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);
- if (ret == (size_t)-1) {
- return 0;
- }
-
- len += ret;
-
- return len;
-}
-
-
-/**
- * Copy a string from a unix char* src to a UCS2 destination,
- * allocating a buffer using talloc().
- *
- * @param dest always set at least to NULL
- *
- * @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, struct smb_iconv_convenience *ic, void **dest, const char *src)
-{
- size_t src_len = strlen(src)+1;
- *dest = NULL;
- return convert_string_talloc(ctx, ic, CH_UNIX, CH_UTF16, src, src_len, dest);
-}
-
-
-/**
- * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_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, ic, CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
-}
-
-/**
- Copy a string from a ucs2 source to a unix char* destination.
- Flags can have:
- STR_TERMINATE means the string in src is null terminated.
- STR_NOALIGN means don't try to align.
- if STR_TERMINATE is set then src_len is ignored if it is -1.
- src_len is the length of the source area in bytes
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-**/
-
-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;
-
- if (ucs2_align(NULL, src, flags)) {
- src = (const void *)((const char *)src + 1);
- if (src_len > 0)
- src_len--;
- }
-
- if (flags & STR_TERMINATE) {
- if (src_len == (size_t)-1) {
- src_len = utf16_len(src);
- } else {
- src_len = utf16_len_n(src, src_len);
- }
- }
-
- /* ucs2 is always a multiple of 2 bytes */
- if (src_len != (size_t)-1)
- src_len &= ~1;
-
- ret = convert_string(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len);
- if (dest_len)
- dest[MIN(ret, dest_len-1)] = 0;
-
- return src_len;
-}
-
-/**
- * Copy a string from a ASCII src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_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, ic, CH_DOS, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_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, ic, CH_UTF16, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- *
- * @returns The number of bytes occupied by the string in the destination
- **/
-
-_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, ic, CH_UTF8, CH_UNIX, src, src_len, (void **)dest);
-}
-
-/**
- Copy a string from a char* src to a unicode or ascii
- dos codepage destination choosing unicode or ascii based on the
- flags in the SMB buffer starting at base_ptr.
- Return the number of bytes occupied by the string in the destination.
- flags can have:
- STR_TERMINATE means include the null termination.
- STR_UPPER means uppercase in the destination.
- STR_ASCII use ascii even with unicode packet.
- STR_NOALIGN means don't do alignment.
- dest_len is the maximum length allowed in the destination. If dest_len
- is -1 then no maxiumum is used.
-**/
-
-_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(ic, dest, src, dest_len, flags);
- } else if (flags & STR_UNICODE) {
- 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;
- }
-}
-
-
-/**
- Copy a string from a unicode or ascii source (depending on
- the packet flags) to a char* destination.
- Flags can have:
- STR_TERMINATE means the string in src is null terminated.
- STR_UNICODE means to force as unicode.
- STR_ASCII use ascii even with unicode packet.
- STR_NOALIGN means don't do alignment.
- if STR_TERMINATE is set then src_len is ignored is it is -1
- src_len is the length of the source area in bytes.
- Return the number of bytes occupied by the string in src.
- The resulting string in "dest" is always null terminated.
-**/
-
-_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(ic, dest, src, dest_len, src_len, flags);
- } else if (flags & STR_UNICODE) {
- 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;
- }
-}
-
-
/*
return the unicode codepoint for the next multi-byte CH_UNIX character
in the string
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 4f7167736a..cba8aaf5f3 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -76,7 +76,6 @@ typedef struct smb_iconv_s {
struct loadparm_context;
struct smb_iconv_convenience;
-extern struct smb_iconv_convenience *global_smb_iconv_convenience;
/* replace some string functions with multi-byte
versions */
@@ -105,6 +104,15 @@ bool strhaslower(const char *string);
char *strrchr_m(const char *s, char c);
char *strchr_m(const char *s, char c);
+ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src);
+ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src);
+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);
+
/* codepoints */
codepoint_t next_codepoint(struct smb_iconv_convenience *ic,
const char *str, size_t *size);
@@ -113,9 +121,13 @@ ssize_t push_codepoint(struct smb_iconv_convenience *ic,
codepoint_t toupper_m(codepoint_t val);
codepoint_t tolower_m(codepoint_t val);
int codepoint_cmpi(codepoint_t c1, codepoint_t c2);
-ssize_t push_string(struct smb_iconv_convenience *ic, void *dest, const char *src, size_t dest_len, int flags);
-ssize_t pull_string(struct smb_iconv_convenience *ic,
- char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
+
+/* Iconv convenience functions */
+struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
+ const char *dos_charset,
+ const char *unix_charset,
+ bool native_iconv);
+
ssize_t convert_string(struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
@@ -126,13 +138,6 @@ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
charset_t from, charset_t to,
void const *src, size_t srclen,
void **dest);
-ssize_t push_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, void **dest, const char *src);
-ssize_t push_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const void *src);
-ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src);
-
/* iconv */
smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode);
int smb_iconv_close(smb_iconv_t cd);
@@ -142,12 +147,6 @@ size_t smb_iconv(smb_iconv_t cd,
smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
const char *fromcode, bool native_iconv);
-/* iconv convenience */
-struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
- const char *dos_charset,
- const char *unix_charset,
- bool native_iconv);
-
void load_case_tables(void);
bool charset_register_backend(const void *_funcs);
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index c53c13b7d0..85f9755557 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -596,3 +596,332 @@ _PUBLIC_ size_t count_chars_m(const char *s, char c)
}
+/**
+ * Copy a string from a char* unix src to a dos codepage string destination.
+ *
+ * @return the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can include
+ * <dl>
+ * <dt>STR_TERMINATE</dt> <dd>means include the null termination</dd>
+ * <dt>STR_UPPER</dt> <dd>means uppercase in the destination</dd>
+ * </dl>
+ *
+ * @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)
+{
+ 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);
+ if (tmpbuf == NULL) {
+ return -1;
+ }
+ ret = push_ascii(dest, tmpbuf, dest_len, flags & ~STR_UPPER);
+ talloc_free(tmpbuf);
+ return ret;
+ }
+
+ src_len = strlen(src);
+
+ if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
+ src_len++;
+
+ return convert_string(ic, CH_UNIX, CH_DOS, src, src_len, dest, dest_len);
+}
+
+/**
+ * Copy a string from a unix char* src to an ASCII destination,
+ * allocating a buffer using talloc().
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+
+/**
+ * Copy a string from a dos codepage source to a unix char* destination.
+ *
+ * The resulting string in "dest" is always null terminated.
+ *
+ * @param flags can have:
+ * <dl>
+ * <dt>STR_TERMINATE</dt>
+ * <dd>STR_TERMINATE means the string in @p src
+ * is null terminated, and src_len is ignored.</dd>
+ * </dl>
+ *
+ * @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)
+{
+ struct smb_iconv_convenience *ic = get_iconv_convenience();
+ size_t ret;
+
+ if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) {
+ if (src_len == (size_t)-1) {
+ src_len = strlen((const char *)src) + 1;
+ } else {
+ size_t len = strnlen((const char *)src, src_len);
+ if (len < src_len)
+ len++;
+ src_len = 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;
+
+ return src_len;
+}
+
+/**
+ * Copy a string from a char* src to a unicode destination.
+ *
+ * @returns the number of bytes occupied by the string in the destination.
+ *
+ * @param flags can have:
+ *
+ * <dl>
+ * <dt>STR_TERMINATE <dd>means include the null termination.
+ * <dt>STR_UPPER <dd>means uppercase in the destination.
+ * <dt>STR_NOALIGN <dd>means don't do alignment.
+ * </dl>
+ *
+ * @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)
+{
+ struct smb_iconv_convenience *ic = get_iconv_convenience();
+ size_t len=0;
+ size_t src_len = strlen(src);
+ size_t ret;
+
+ if (flags & STR_UPPER) {
+ char *tmpbuf = strupper_talloc(NULL, src);
+ if (tmpbuf == NULL) {
+ return -1;
+ }
+ ret = push_ucs2(dest, tmpbuf, dest_len, flags & ~STR_UPPER);
+ talloc_free(tmpbuf);
+ return ret;
+ }
+
+ if (flags & STR_TERMINATE)
+ src_len++;
+
+ if (ucs2_align(NULL, dest, flags)) {
+ *(char *)dest = 0;
+ dest = (void *)((char *)dest + 1);
+ if (dest_len) dest_len--;
+ len++;
+ }
+
+ /* 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);
+ if (ret == (size_t)-1) {
+ return 0;
+ }
+
+ len += ret;
+
+ return len;
+}
+
+
+/**
+ * Copy a string from a unix char* src to a UCS2 destination,
+ * allocating a buffer using talloc().
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+
+/**
+ * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+/**
+ Copy a string from a ucs2 source to a unix char* destination.
+ Flags can have:
+ STR_TERMINATE means the string in src is null terminated.
+ STR_NOALIGN means don't try to align.
+ if STR_TERMINATE is set then src_len is ignored if it is -1.
+ src_len is the length of the source area in bytes
+ Return the number of bytes occupied by the string in 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)
+{
+ struct smb_iconv_convenience *ic = get_iconv_convenience();
+ size_t ret;
+
+ if (ucs2_align(NULL, src, flags)) {
+ src = (const void *)((const char *)src + 1);
+ if (src_len > 0)
+ src_len--;
+ }
+
+ if (flags & STR_TERMINATE) {
+ if (src_len == (size_t)-1) {
+ src_len = utf16_len(src);
+ } else {
+ src_len = utf16_len_n(src, src_len);
+ }
+ }
+
+ /* ucs2 is always a multiple of 2 bytes */
+ if (src_len != (size_t)-1)
+ src_len &= ~1;
+
+ ret = convert_string(ic, CH_UTF16, CH_UNIX, src, src_len, dest, dest_len);
+ if (dest_len)
+ dest[MIN(ret, dest_len-1)] = 0;
+
+ return src_len;
+}
+
+/**
+ * Copy a string from a ASCII src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+/**
+ * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+/**
+ * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @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)
+{
+ 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);
+}
+
+/**
+ Copy a string from a char* src to a unicode or ascii
+ dos codepage destination choosing unicode or ascii based on the
+ flags in the SMB buffer starting at base_ptr.
+ Return the number of bytes occupied by the string in the destination.
+ flags can have:
+ STR_TERMINATE means include the null termination.
+ STR_UPPER means uppercase in the destination.
+ STR_ASCII use ascii even with unicode packet.
+ STR_NOALIGN means don't do alignment.
+ dest_len is the maximum length allowed in the destination. If dest_len
+ is -1 then no maxiumum is used.
+**/
+
+_PUBLIC_ ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags)
+{
+ if (flags & STR_ASCII) {
+ return push_ascii(dest, src, dest_len, flags);
+ } else if (flags & STR_UNICODE) {
+ return push_ucs2(dest, src, dest_len, flags);
+ } else {
+ smb_panic("push_string requires either STR_ASCII or STR_UNICODE flag to be set");
+ return -1;
+ }
+}
+
+
+/**
+ Copy a string from a unicode or ascii source (depending on
+ the packet flags) to a char* destination.
+ Flags can have:
+ STR_TERMINATE means the string in src is null terminated.
+ STR_UNICODE means to force as unicode.
+ STR_ASCII use ascii even with unicode packet.
+ STR_NOALIGN means don't do alignment.
+ if STR_TERMINATE is set then src_len is ignored is it is -1
+ src_len is the length of the source area in bytes.
+ Return the number of bytes occupied by the string in src.
+ 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)
+{
+ if (flags & STR_ASCII) {
+ return pull_ascii(dest, src, dest_len, src_len, flags);
+ } else if (flags & STR_UNICODE) {
+ return pull_ucs2(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;
+ }
+}
+
+
diff --git a/source4/auth/ntlm/auth_util.c b/source4/auth/ntlm/auth_util.c
index 64ceb437ad..2f8ef10e05 100644
--- a/source4/auth/ntlm/auth_util.c
+++ b/source4/auth/ntlm/auth_util.c
@@ -145,7 +145,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
chall_blob = data_blob_talloc(mem_ctx, challenge, 8);
if (lp_client_ntlmv2_auth(auth_context->lp_ctx)) {
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(auth_context->lp_ctx), lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key;
if (!SMBNTLMv2encrypt_hash(user_info_temp,
diff --git a/source4/auth/ntlmssp/ntlmssp_client.c b/source4/auth/ntlmssp/ntlmssp_client.c
index eb990dee9c..0ef40200fe 100644
--- a/source4/auth/ntlmssp/ntlmssp_client.c
+++ b/source4/auth/ntlmssp/ntlmssp_client.c
@@ -73,7 +73,6 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
/* generate the ntlmssp negotiate packet */
msrpc_gen(out_mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
out, "CddAA",
"NTLMSSP",
NTLMSSP_NEGOTIATE,
@@ -258,7 +257,6 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
/* this generates the actual auth packet */
if (!msrpc_gen(mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
out, auth_gen_string,
"NTLMSSP",
NTLMSSP_AUTH,
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c
index 9256872036..cd270590f1 100644
--- a/source4/auth/ntlmssp/ntlmssp_parse.c
+++ b/source4/auth/ntlmssp/ntlmssp_parse.c
@@ -42,7 +42,6 @@
C = constant ascii string
*/
bool msrpc_gen(TALLOC_CTX *mem_ctx,
- struct smb_iconv_convenience *iconv_convenience,
DATA_BLOB *blob,
const char *format, ...)
{
@@ -67,7 +66,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
case 'U':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -78,7 +77,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
case 'A':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ascii_talloc(pointers, iconv_convenience, (char **)&pointers[i].data, s);
+ n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -90,7 +89,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
n = va_arg(ap, int);
intargs[i] = n;
s = va_arg(ap, char *);
- n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
+ n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
if (n == -1) {
return false;
}
@@ -248,7 +247,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
}
if (0 < len1) {
- pull_string(iconv_convenience, p, blob->data + ptr, p_len,
+ pull_string(p, blob->data + ptr, p_len,
len1, STR_UNICODE|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
@@ -283,7 +282,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
}
if (0 < len1) {
- pull_string(iconv_convenience, p, blob->data + ptr, p_len,
+ pull_string(p, blob->data + ptr, p_len,
len1, STR_ASCII|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
@@ -348,7 +347,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
goto cleanup;
}
- head_ofs += pull_string(iconv_convenience, p,
+ head_ofs += pull_string(p,
blob->data+head_ofs, p_len,
blob->length - head_ofs,
STR_ASCII|STR_TERMINATE);
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index ad1ee8e871..38973f623d 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -205,7 +205,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
}
msrpc_gen(out_mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
&struct_blob, "aaaaa",
NTLMSSP_NAME_TYPE_DOMAIN, target_name,
NTLMSSP_NAME_TYPE_SERVER, gensec_ntlmssp_state->server_name,
@@ -226,7 +225,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
}
msrpc_gen(out_mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
out, gen_string,
"NTLMSSP",
NTLMSSP_CHALLENGE,
diff --git a/source4/auth/ntlmssp/ntlmssp_sign.c b/source4/auth/ntlmssp/ntlmssp_sign.c
index 49ed48df98..47d7a2104a 100644
--- a/source4/auth/ntlmssp/ntlmssp_sign.c
+++ b/source4/auth/ntlmssp/ntlmssp_sign.c
@@ -119,7 +119,6 @@ static NTSTATUS ntlmssp_make_packet_signature(struct gensec_ntlmssp_state *gense
uint32_t crc;
crc = crc32_calc_buffer(data, length);
if (!msrpc_gen(sig_mem_ctx,
- lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
return NT_STATUS_NO_MEMORY;
}
@@ -248,7 +247,6 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
uint32_t crc;
crc = crc32_calc_buffer(data, length);
if (!msrpc_gen(sig_mem_ctx,
- lp_iconv_convenience(gensec_security->lp_ctx),
sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c
index 1336b0157e..63b5f2a2e4 100644
--- a/source4/kdc/kpasswdd.c
+++ b/source4/kdc/kpasswdd.c
@@ -65,7 +65,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, lp_iconv_convenience(kdc->task->lp_ctx), &error_string_utf8, error_string);
+ len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string);
if (len == -1) {
return false;
}
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index a78c444da7..2803aaff5e 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -67,7 +67,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
int len;
void *wpwd;
- len = push_ucs2_talloc(NULL, lp_iconv_convenience(global_loadparm), &wpwd, passwd);
+ len = push_ucs2_talloc(NULL, &wpwd, passwd);
if (len < 2) {
/* We don't want to return fixed data, as most callers
* don't check */
@@ -97,7 +97,7 @@ 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(lp_iconv_convenience(global_loadparm), dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
+ push_string(dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
/* Only the first 14 chars are considered, password need not be null terminated. */
E_P16((const uint8_t *)dospwd, p16);
@@ -124,7 +124,6 @@ bool ntv2_owf_gen(const uint8_t owf[16],
HMACMD5Context ctx;
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
- struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
if (!mem_ctx) {
return false;
@@ -152,14 +151,14 @@ bool ntv2_owf_gen(const uint8_t owf[16],
}
}
- user_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &user, user_in);
+ user_byte_len = push_ucs2_talloc(mem_ctx, &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, iconv_convenience, &domain, domain_in);
+ domain_byte_len = push_ucs2_talloc(mem_ctx, &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);
@@ -295,13 +294,12 @@ void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16],
}
DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx,
- struct smb_iconv_convenience *iconv_convenience,
const char *hostname,
const char *domain)
{
DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0);
- msrpc_gen(mem_ctx, iconv_convenience, &names_blob,
+ msrpc_gen(mem_ctx, &names_blob,
"aaa",
NTLMSSP_NAME_TYPE_DOMAIN, domain,
NTLMSSP_NAME_TYPE_SERVER, hostname,
@@ -324,7 +322,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO
/* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */
- msrpc_gen(mem_ctx, NULL, &response, "ddbbdb",
+ msrpc_gen(mem_ctx, &response, "ddbbdb",
0x00000101, /* Header */
0, /* 'Reserved' */
long_date, 8, /* Timestamp */
@@ -472,7 +470,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(lp_iconv_convenience(global_loadparm), new_pw,
+ new_pw_len = push_string(new_pw,
password,
sizeof(new_pw), string_flags);
@@ -525,7 +523,7 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
}
/* decode into the return buffer. Buffer length supplied */
- converted_pw_len = pull_string(lp_iconv_convenience(global_loadparm), new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size,
+ converted_pw_len = pull_string(new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size,
byte_len, string_flags);
if (converted_pw_len == -1) {
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 353b66c622..caef28d7fc 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -430,7 +430,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(lp_iconv_convenience(global_loadparm), req->out.data + req->out.data_size, str, len, flags);
+ len = push_string(req->out.data + req->out.data_size, str, len, flags);
smbcli_req_grow_data(req, len + req->out.data_size);
@@ -977,7 +977,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
return 0;
}
- len = push_string(lp_iconv_convenience(global_loadparm), blob->data + blob->length, str, max_len, flags);
+ len = push_string(blob->data + blob->length, str, max_len, flags);
blob->length += len;
diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c
index 645f5362ac..76c1f952e7 100644
--- a/source4/libcli/smb_composite/sesssetup.c
+++ b/source4/libcli/smb_composite/sesssetup.c
@@ -260,7 +260,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
{
NTSTATUS nt_status = NT_STATUS_INTERNAL_ERROR;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key = data_blob(NULL, 0);
int flags = CLI_CRED_NTLM_AUTH;
@@ -334,7 +334,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
NTSTATUS nt_status;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
const char *password = cli_credentials_get_password(io->in.credentials);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = 0;
if (session->options.lanman_auth) {
diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c
index a36a66b80f..60c95a3bd0 100644
--- a/source4/nsswitch/wbinfo.c
+++ b/source4/nsswitch/wbinfo.c
@@ -836,7 +836,7 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
server_chal = data_blob(request.data.auth_crap.chal, 8);
/* Pretend this is a login to 'us', for blob purposes */
- names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_iconv_convenience(lp_ctx), lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx));
+ names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx));
if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal,
&names_blob,
diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c
index aa9b11a973..540e51a43b 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(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
- push_string(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
+ push_string(p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
+ push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
return NT_STATUS_OK;
}
diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c
index bd250361a4..baa9b3e4d8 100644
--- a/source4/smb_server/blob.c
+++ b/source4/smb_server/blob.c
@@ -140,10 +140,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(lp_iconv_convenience(global_loadparm), blob->data + offset + 1, str, dest_len-1, flags);
+ ret = push_string(blob->data + offset + 1, str, dest_len-1, flags);
}
} else {
- ret = push_string(lp_iconv_convenience(global_loadparm), blob->data + offset, str, dest_len, flags);
+ ret = push_string(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 4a06ea4b91..3480711ed2 100644
--- a/source4/smb_server/smb/nttrans.c
+++ b/source4/smb_server/smb/nttrans.c
@@ -398,7 +398,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(lp_iconv_convenience(global_loadparm), p + 12, info->nttrans.out.changes[i].name.s,
+ len = push_string(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 241c262857..52eb69fe68 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -428,7 +428,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(lp_iconv_convenience(req->smb_conn->lp_ctx), dest, str, len, flags);
+ len = push_string(dest, str, len, flags);
grow_size = len + PTR_DIFF(dest, req->out.data);
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index 4f4402ba33..221fafadfd 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -458,7 +458,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(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p + 12, io->smb2.out.changes[i].name.s,
+ len = push_string(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/scanner.c b/source4/torture/basic/scanner.c
index 5212f1edee..7f88662baa 100644
--- a/source4/torture/basic/scanner.c
+++ b/source4/torture/basic/scanner.c
@@ -163,7 +163,7 @@ static bool trans2_op_exists(struct smbcli_state *cli, int op)
/****************************************************************************
check for existance of a trans2 call
****************************************************************************/
-static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
+static bool scan_trans2(
struct smbcli_state *cli, int op, int level,
int fnum, int dnum, int qfnum, const char *fname)
{
@@ -233,7 +233,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
SSVAL(param, 0, level);
SSVAL(param, 2, 0);
SSVAL(param, 4, 0);
- param_len += push_string(iconv_convenience,
+ param_len += push_string(
&param[6], fname, PARAM_SIZE-7,
STR_TERMINATE|STR_UNICODE);
@@ -249,7 +249,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
SSVAL(param, 0, level);
SSVAL(param, 2, 0);
SSVAL(param, 4, 0);
- param_len += push_string(iconv_convenience,
+ param_len += push_string(
&param[6], "\\newfile.dat", PARAM_SIZE-7,
STR_TERMINATE|STR_UNICODE);
@@ -266,7 +266,7 @@ static bool scan_trans2(struct smb_iconv_convenience *iconv_convenience,
smbcli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
- param_len += push_string(iconv_convenience,
+ param_len += push_string(
&param[2], "\\testdir", PARAM_SIZE-3,
STR_TERMINATE|STR_UNICODE);
@@ -321,15 +321,15 @@ bool torture_trans2_scan(struct torture_context *torture,
}
for (level = 0; level <= 50; level++) {
- scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+ scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
}
for (level = 0x100; level <= 0x130; level++) {
- scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+ scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
}
for (level = 1000; level < 1050; level++) {
- scan_trans2(lp_iconv_convenience(torture->lp_ctx), cli, op, level, fnum, dnum, qfnum, fname);
+ scan_trans2(cli, op, level, fnum, dnum, qfnum, fname);
}
}
@@ -494,7 +494,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
SSVAL(param, 0, level);
SSVAL(param, 2, 0);
SSVAL(param, 4, 0);
- param_len += push_string(iconv_convenience,
+ param_len += push_string(
&param[6], fname, PARAM_SIZE,
STR_TERMINATE | STR_UNICODE);
@@ -510,7 +510,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
SSVAL(param, 0, level);
SSVAL(param, 2, 0);
SSVAL(param, 4, 0);
- param_len += push_string(iconv_convenience,
+ param_len += push_string(
&param[6], "\\newfile.dat", PARAM_SIZE,
STR_TERMINATE | STR_UNICODE);
@@ -527,8 +527,7 @@ static bool scan_nttrans(struct smb_iconv_convenience *iconv_convenience,
smbcli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
- param_len += push_string(iconv_convenience,
- &param[2], "\\testdir", PARAM_SIZE,
+ param_len += push_string(&param[2], "\\testdir", PARAM_SIZE,
STR_TERMINATE | STR_UNICODE);
status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len,
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index e93bd52b9a..be231107dd 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -184,7 +184,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(ndr->iconv_convenience, *dest, p, len+1, len, STR_ASCII);
+ pull_string(*dest, p, len+1, len, STR_ASCII);
return NT_STATUS_OK;
}
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index f4ae5b35eb..c2e12ec01d 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -592,7 +592,7 @@ bool test_netlogon_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
chal = data_blob_const(ninfo.challenge,
sizeof(ninfo.challenge));
- names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials),
+ names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials),
cli_credentials_get_domain(credentials));
status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 260c1cc149..25ff7d0ea9 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -1041,7 +1041,7 @@ static bool schan(struct smbcli_state *cli,
generate_random_buffer(chal.data, chal.length);
names_blob = NTLMv2_generate_names_blob(
- mem_ctx, lp_iconv_convenience(lp_ctx),
+ mem_ctx,
cli_credentials_get_workstation(user_creds),
cli_credentials_get_domain(user_creds));
status = cli_credentials_get_ntlm_response(
@@ -2420,8 +2420,7 @@ 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, iconv_convenience,
- name, servername) < 0) {
+ if (pull_ascii_talloc(mem_ctx, name, servername) < 0) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index b7028e6609..01368cccad 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -595,7 +595,7 @@ static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
DATA_BLOB lmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, TEST_MACHINE_NAME, samlogon_state->workgroup);
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, samlogon_state->workgroup);
uint8_t lm_session_key[8];
uint8_t user_session_key[16];
@@ -743,7 +743,7 @@ static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
DATA_BLOB lmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, samlogon_state->netbios_name, samlogon_state->workgroup);
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->netbios_name, samlogon_state->workgroup);
DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16);
@@ -1162,7 +1162,6 @@ 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,
- samlogon_state->iconv_convenience,
&unicodepw, samlogon_state->password)) == -1) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
exit(1);
diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c
index fae0093e4d..15d40a2e17 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -68,7 +68,7 @@ bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
chal = data_blob_const(ninfo.challenge,
sizeof(ninfo.challenge));
- names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials),
+ names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials),
cli_credentials_get_domain(credentials));
status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
@@ -573,7 +573,7 @@ static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *con
chal = data_blob_const(conn->ninfo.challenge,
sizeof(conn->ninfo.challenge));
- names_blob = NTLMv2_generate_names_blob(conn->tmp, lp_iconv_convenience(s->tctx->lp_ctx),
+ names_blob = NTLMv2_generate_names_blob(conn->tmp,
cli_credentials_get_workstation(conn->wks_creds),
cli_credentials_get_domain(conn->wks_creds));
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 015f20f6e2..0f49562d8b 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -966,8 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx,
size_t size;
uint8_t *msg;
- size = push_ucs2_talloc(tctx, lp_iconv_convenience(tctx->lp_ctx),
- (void **)&msg, message);
+ size = push_ucs2_talloc(tctx, (void **)&msg, message);
r.in.server_name = dcerpc_server_name(p);
r.in.message_name = dcerpc_server_name(p);
diff --git a/source4/winbind/wb_pam_auth.c b/source4/winbind/wb_pam_auth.c
index ee54bcd58f..5913f8d1bf 100644
--- a/source4/winbind/wb_pam_auth.c
+++ b/source4/winbind/wb_pam_auth.c
@@ -245,7 +245,6 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
names_blob = NTLMv2_generate_names_blob(
mem_ctx,
- lp_iconv_convenience(service->task->lp_ctx),
cli_credentials_get_workstation(credentials),
cli_credentials_get_domain(credentials));