Remove iconv_convenience parameter from simple string push/pull
authorJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 01:40:09 +0000 (03:40 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 01:40:09 +0000 (03:40 +0200)
functions.

26 files changed:
lib/util/charset/charcnv.c
lib/util/charset/charset.h
lib/util/charset/util_unistr.c
source4/auth/ntlm/auth_util.c
source4/auth/ntlmssp/ntlmssp_client.c
source4/auth/ntlmssp/ntlmssp_parse.c
source4/auth/ntlmssp/ntlmssp_server.c
source4/auth/ntlmssp/ntlmssp_sign.c
source4/kdc/kpasswdd.c
source4/libcli/auth/smbencrypt.c
source4/libcli/raw/rawrequest.c
source4/libcli/smb_composite/sesssetup.c
source4/nsswitch/wbinfo.c
source4/ntvfs/print/vfs_print.c
source4/smb_server/blob.c
source4/smb_server/smb/nttrans.c
source4/smb_server/smb/request.c
source4/smb_server/smb2/fileio.c
source4/torture/basic/scanner.c
source4/torture/rap/rap.c
source4/torture/rpc/netlogon.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/schannel.c
source4/torture/rpc/wkssvc.c
source4/winbind/wb_pam_auth.c

index 35119e53954f6459f828300c214c20d63a40b040..91a16a1cdae4c8f1b973afafbdc6bdfa98dc3c05 100644 (file)
@@ -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
index 4f7167736a0c130bd9b0db1a49f26bdab0c0e15c..cba8aaf5f3af75739d841a2d1b327c92f7c12e6d 100644 (file)
@@ -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);
 
index c53c13b7d0aa3dbea46984c086e7b8d34611ab46..85f9755557fd726cc9d355b9483eab7b5b0431c5 100644 (file)
@@ -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;
+       }
+}
+
+
index 64ceb437ad6dc4b9a3ba71ab23811ef52144a3fb..2f8ef10e05a3c54c0d72a691fa2b94f19a1397d1 100644 (file)
@@ -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,
index eb990dee9cb5b350bed89c943f8bee4c3caa2796..0ef40200fe5eb3f5c1fc7edb1798e2f4bffa59b4 100644 (file)
@@ -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, 
index 9256872036de5cb29208a4d2027cc02ab61a7998..cd270590f15547cfa4e5f45788811c0803821d15 100644 (file)
@@ -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);
index ad1ee8e871b6d045a69db776bbeed6d0d2c6cb46..38973f623d4da2b827d049b3855a150167fca4d3 100644 (file)
@@ -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,
index 49ed48df984eefc5a66b64e553cb099671f925c8..47d7a2104a648a64d70f44f149c5735a5d497fdf 100644 (file)
@@ -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;
                }
index 1336b0157ecc03eda7e7b915d2128b05d55419da..63b5f2a2e4de70601abb0d48e54ccec37725a9ad 100644 (file)
@@ -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;
        }
index a78c444da79df69940f8536b9acc4165cc7fe1f9..2803aaff5e3bbb82f1eb46ecc94d090f21c02847 100644 (file)
@@ -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) {
index 353b66c6220271a808688a73ef5e121e41aebaed..caef28d7fc25f40f28ff597b6277a437dd85af4a 100644 (file)
@@ -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;
 
index 645f5362ac30238d5ec3a2c57ff74b504d9eeb19..76c1f952e79fbe3554eacdf2a3bf90a135971f66 100644 (file)
@@ -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) {
index a36a66b80f3dabba78e685c640ed29e1e61ce3b4..60c95a3bd06d95a4864e83c9ea3ab4e44f6aa553 100644 (file)
@@ -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,
index aa9b11a9737ebae0ba395441cf66a8792f4843e7..540e51a43b779a3ed6ecb12d3e1829497f3807b9 100644 (file)
@@ -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;
        }
 
index bd250361a402d0cebe00dcd15ac21baa101851e6..baa9b3e4d80939c9460eafcf578fd33d7bb16e4e 100644 (file)
@@ -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
index 4a06ea4b91e04869853207b444a2cfb2294d61b7..3480711ed20bfc2df42e7897760fb45637e05efc 100644 (file)
@@ -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);
index 241c2628572c2fdd1acb9fa8ab41bac92fc302b2..52eb69fe68fbb3d10915e22a08f968fc2d949ae5 100644 (file)
@@ -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);
 
index 4f4402ba3301d2e11ab20958807376c6d925ce70..221fafadfdbfe8612af383ffd1b9199c6fd4f41c 100644 (file)
@@ -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);
 
index 5212f1edeec21b879479591fbde0da1c3c83b640..7f88662baa5fe6c4163e6e24f5a8eaa393513e0a 100644 (file)
@@ -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,
index e93bd52b9a7d6586b59fc3ea4c062566eaf5705c..be231107dd6e9240786ffcf3ac0fd6f9828d0ffd 100644 (file)
@@ -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;
 }
index f4ae5b35ebcc72c2471b7f5b61683d51c314719f..c2e12ec01dbb1425f01d614185ba9a9e23ebea5e 100644 (file)
@@ -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, 
index 260c1cc1499bc6baeb74f19b8c940352e00e0d49..25ff7d0ea9b4052c8ec5360836e2d73f18c69495 100644 (file)
@@ -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;
        }
 
index b7028e660959d5e74d46ea0fa6db585ab742c206..01368cccad950fe32b6367134eeb34fd43d207c2 100644 (file)
@@ -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);
index fae0093e4d12a5fb3d4344036be3d5581f6273e4..15d40a2e176a3250c8c14a7e1717eeef9c9f3bc4 100644 (file)
@@ -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));
 
index 015f20f6e2cdbc815c4d2fc7df1cdee8cf508e16..0f49562d8b334bcf32cb59a23742f732b9254bcd 100644 (file)
@@ -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);
index ee54bcd58f7818a1873b53c53e0f0aea007fc9e2..5913f8d1bfe704147d660e2bc1da3ef327a3a406 100644 (file)
@@ -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));