[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-110-g9940c76

Jelmer Vernooij jelmer at samba.org
Sun Mar 1 21:31:37 GMT 2009


The branch, master has been updated
       via  9940c7690e2c1b225111d5d8e09cc735ebe296dd (commit)
       via  9551ab8f7b0e69349dc0c1ffb70a6f67163b242c (commit)
       via  7ab8f373c84c328b197f923287163e83371e7ccb (commit)
       via  94069bd2747a8397308c0b0b384f7bb4edd8f68b (commit)
      from  8568b4fa9ff8f6f1a24547ec2ed5e2942b213d9e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9940c7690e2c1b225111d5d8e09cc735ebe296dd
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Mar 1 22:31:10 2009 +0100

    Use shared header file for character sets, remove old definitions from samba3 smb.h.

commit 9551ab8f7b0e69349dc0c1ffb70a6f67163b242c
Merge: 7ab8f373c84c328b197f923287163e83371e7ccb 8568b4fa9ff8f6f1a24547ec2ed5e2942b213d9e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Mar 1 22:25:57 2009 +0100

    Merge branch 'master' of git://git.samba.org/samba into convenience

commit 7ab8f373c84c328b197f923287163e83371e7ccb
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Mar 1 22:24:34 2009 +0100

    Use common header file for character set handling in Samba 3 and Samba 4.

commit 94069bd2747a8397308c0b0b384f7bb4edd8f68b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Mar 1 19:55:46 2009 +0100

    s4: Use same function signature for convert_* as s3.

-----------------------------------------------------------------------

Summary of changes:
 lib/util/charset/charcnv.c                     |   42 +++++---
 lib/util/charset/charset.h                     |  125 ++++++++++++++++++++---
 lib/util/charset/iconv.c                       |    1 +
 lib/util/charset/tests/iconv.c                 |   11 +--
 lib/util/charset/util_unistr.c                 |   44 +++++----
 source3/Makefile.in                            |    4 +-
 source3/include/charset.h                      |  128 ------------------------
 source3/include/includes.h                     |    2 +-
 source3/include/proto.h                        |    3 +-
 source3/include/smb.h                          |   18 ----
 source3/lib/charcnv.c                          |    2 +-
 source3/lib/iconv.c                            |    4 +-
 source4/auth/ntlm/ntlm_check.c                 |    2 +-
 source4/auth/ntlmssp/ntlmssp_parse.c           |   36 ++++---
 source4/dsdb/common/util.c                     |    2 +-
 source4/dsdb/samdb/ldb_modules/password_hash.c |   17 ++--
 source4/dsdb/schema/schema_init.c              |    7 +-
 source4/dsdb/schema/schema_syntax.c            |   24 ++---
 source4/kdc/kpasswdd.c                         |   18 ++--
 source4/lib/registry/ldb.c                     |    8 +-
 source4/lib/registry/tests/generic.c           |   12 +-
 source4/lib/registry/util.c                    |    6 +-
 source4/lib/tdr/tdr.c                          |   12 +--
 source4/libcli/auth/smbencrypt.c               |   32 +++---
 source4/libcli/raw/rawfileinfo.c               |    8 +-
 source4/libcli/raw/rawrequest.c                |   32 ++++---
 source4/libcli/smb2/request.c                  |   18 ++--
 source4/libnet/libnet_samdump.c                |    4 +-
 source4/librpc/ndr/ndr_string.c                |   56 ++++------
 source4/rpc_server/samr/samr_password.c        |   15 ++--
 source4/smb_server/smb/request.c               |   12 +-
 source4/torture/basic/charset.c                |    5 +-
 source4/torture/basic/utable.c                 |   13 ++-
 source4/torture/rpc/samba3rpc.c                |    2 +-
 source4/torture/rpc/samlogon.c                 |   10 +-
 source4/torture/rpc/spoolss_win.c              |    2 +-
 source4/torture/rpc/wkssvc.c                   |    2 +-
 37 files changed, 345 insertions(+), 394 deletions(-)
 delete mode 100644 source3/include/charset.h


Changeset truncated at 500 lines:

diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c
index 18be2bc..258730e 100644
--- a/lib/util/charset/charcnv.c
+++ b/lib/util/charset/charcnv.c
@@ -186,7 +186,7 @@ convert:
 	destlen = 2 + (destlen*3);
 	ob = talloc_realloc(ctx, outbuf, char, destlen);
 	if (!ob) {
-		DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
+		DEBUG(0, ("iconv_talloc: realloc failed!\n"));
 		talloc_free(outbuf);
 		return (size_t)-1;
 	} else {
@@ -237,10 +237,11 @@ convert:
  * @param destlen maximal length allowed for string
  * @returns the number of bytes occupied in the destination
  **/
-_PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
+_PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic,
 				charset_t from, charset_t to,
 				void const *src, size_t srclen, 
-				void *dest, size_t destlen, bool allow_badcharcnv)
+				void *dest, size_t destlen, size_t *converted_size,
+				bool allow_badcharcnv)
 {
 	size_t i_len, o_len;
 	size_t retval;
@@ -249,7 +250,8 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
 	smb_iconv_t descriptor;
 
 	if (allow_badcharcnv) {
-		return -1;
+		/* Not implemented yet */
+		return false;
 	}
 
 	if (srclen == (size_t)-1)
@@ -261,7 +263,8 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
 		/* conversion not supported, use as is */
 		size_t len = MIN(srclen,destlen);
 		memcpy(dest,src,len);
-		return len;
+		*converted_size = len;
+		return true;
 	}
 
 	i_len=srclen;
@@ -272,7 +275,7 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
 		switch(errno) {
 			case EINVAL:
 				reason="Incomplete multibyte sequence";
-				return -1;
+				return false;
 			case E2BIG:
 				reason="No more room"; 
 				if (from == CH_UNIX) {
@@ -285,14 +288,16 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
 						 charset_name(ic, from), charset_name(ic, to),
 						 (int)srclen, (int)destlen));
 				}
-			       return -1;
+			       return false;
 			case EILSEQ:
 			       reason="Illegal multibyte sequence";
-			       return -1;
+			       return false;
 		}
 		/* smb_panic(reason); */
 	}
-	return destlen-o_len;
+	if (converted_size != NULL)
+		*converted_size = destlen-o_len;
+	return true;
 }
 	
 /**
@@ -305,21 +310,23 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
  * @returns Size in bytes of the converted string; or -1 in case of error.
  **/
 
-_PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx, 
+_PUBLIC_ bool convert_string_talloc_convenience(TALLOC_CTX *ctx, 
 				       struct smb_iconv_convenience *ic, 
 				       charset_t from, charset_t to, 
 				       void const *src, size_t srclen, 
-				       void **dest, bool allow_badcharcnv)
+				       void **dest, size_t *converted_size, 
+					   bool allow_badcharcnv)
 {
 	smb_iconv_t descriptor;
+	ssize_t ret;
 
 	if (allow_badcharcnv)
-		return (size_t)-1;
+		return false; /* Not implemented yet */
 
 	*dest = NULL;
 
 	if (src == NULL || srclen == (size_t)-1 || srclen == 0)
-		return (size_t)-1;
+		return false;
 
 	descriptor = get_conv_handle(ic, from, to);
 
@@ -328,10 +335,15 @@ _PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
 		DEBUG(3, ("convert_string_talloc: conversion from %s to %s not supported!\n",
 			  charset_name(ic, from), 
 			  charset_name(ic, to)));
-		return -1;
+		return false;
 	}
 
-	return iconv_talloc(ctx, descriptor, src, srclen, dest);
+	ret = iconv_talloc(ctx, descriptor, src, srclen, dest);
+	if (ret == -1)
+		return false;
+	if (converted_size != NULL)
+		*converted_size = ret;
+	return true;
 }
 
 /*
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 3acdde3..655bae7 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -28,9 +28,16 @@
 #include <talloc.h>
 
 /* this defines the charset types used in samba */
-typedef enum {CH_UTF16=0, CH_UNIX, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
+typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX, CH_DISPLAY, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
 
-#define NUM_CHARSETS 6
+#define NUM_CHARSETS 7
+
+/*
+ * SMB UCS2 (16-bit unicode) internal type.
+ * smb_ucs2_t is *always* in little endian format.
+ */
+
+typedef uint16_t smb_ucs2_t;
 
 /*
  *   for each charset we have a function that pulls from that charset to
@@ -51,6 +58,17 @@ typedef uint32_t codepoint_t;
 
 #define INVALID_CODEPOINT ((codepoint_t)-1)
 
+/*
+ * This is auxiliary struct used by source/script/gen-8-bit-gap.sh script
+ * during generation of an encoding table for charset module
+ *     */
+
+struct charset_gap_table {
+  uint16_t start;
+  uint16_t end;
+  int32_t idx;
+};
+
 
 /* generic iconv conversion structure */
 typedef struct smb_iconv_s {
@@ -106,19 +124,20 @@ 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);
+bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size);
+bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size);
+bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
 ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags);
 ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
 
-ssize_t convert_string_talloc(TALLOC_CTX *ctx, 
+bool convert_string_talloc(TALLOC_CTX *ctx, 
 				       charset_t from, charset_t to, 
 				       void const *src, size_t srclen, 
-				       void **dest, bool allow_badcharcnv);
+				       void **dest, size_t *converted_size, 
+					   bool allow_badcharcnv);
 
 size_t convert_string(charset_t from, charset_t to,
 				void const *src, size_t srclen, 
@@ -148,15 +167,16 @@ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
 							 const char *unix_charset,
 							 bool native_iconv);
 
-ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
+bool convert_string_convenience(struct smb_iconv_convenience *ic,
 				charset_t from, charset_t to,
 				void const *src, size_t srclen, 
-				void *dest, size_t destlen, bool allow_badcharcnv);
-ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx, 
+				void *dest, size_t destlen, size_t *converted_size,
+				bool allow_badcharcnv);
+bool convert_string_talloc_convenience(TALLOC_CTX *ctx, 
 				       struct smb_iconv_convenience *ic, 
 				       charset_t from, charset_t to, 
 				       void const *src, size_t srclen, 
-				       void **dest, bool allow_badcharcnv);
+				       void **dest, size_t *converted_size, bool allow_badcharcnv);
 /* iconv */
 smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode);
 int smb_iconv_close(smb_iconv_t cd);
@@ -169,4 +189,81 @@ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
 void load_case_tables(void);
 bool charset_register_backend(const void *_funcs);
 
+/*
+ *   Define stub for charset module which implements 8-bit encoding with gaps.
+ *   Encoding tables for such module should be produced from glibc's CHARMAPs
+ *   using script source/script/gen-8bit-gap.sh
+ *   CHARSETNAME is CAPITALIZED charset name
+ *
+ *     */
+#define SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) 					\
+static size_t CHARSETNAME ## _push(void *cd, const char **inbuf, size_t *inbytesleft,			\
+			 char **outbuf, size_t *outbytesleft) 					\
+{ 												\
+	while (*inbytesleft >= 2 && *outbytesleft >= 1) { 					\
+		int i; 										\
+		int done = 0; 									\
+												\
+		uint16 ch = SVAL(*inbuf,0); 							\
+												\
+		for (i=0; from_idx[i].start != 0xffff; i++) {					\
+			if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) {		\
+				((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch];	\
+				(*inbytesleft) -= 2;						\
+				(*outbytesleft) -= 1;						\
+				(*inbuf)  += 2;							\
+				(*outbuf) += 1;							\
+				done = 1;							\
+				break;								\
+			}									\
+		}										\
+		if (!done) {									\
+			errno = EINVAL;								\
+			return -1;								\
+		}										\
+												\
+	}											\
+												\
+	if (*inbytesleft == 1) {								\
+		errno = EINVAL;									\
+		return -1;									\
+	}											\
+												\
+	if (*inbytesleft > 1) {									\
+		errno = E2BIG;									\
+		return -1;									\
+	}											\
+												\
+	return 0;										\
+}												\
+												\
+static size_t CHARSETNAME ## _pull(void *cd, const char **inbuf, size_t *inbytesleft,				\
+			 char **outbuf, size_t *outbytesleft)					\
+{												\
+	while (*inbytesleft >= 1 && *outbytesleft >= 2) {					\
+		*(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]];			\
+		(*inbytesleft)  -= 1;								\
+		(*outbytesleft) -= 2;								\
+		(*inbuf)  += 1;									\
+		(*outbuf) += 2;									\
+	}											\
+												\
+	if (*inbytesleft > 0) {									\
+		errno = E2BIG;									\
+		return -1;									\
+	}											\
+												\
+	return 0;										\
+}												\
+												\
+struct charset_functions CHARSETNAME ## _functions = 						\
+		{#CHARSETNAME, CHARSETNAME ## _pull, CHARSETNAME ## _push};			\
+												\
+NTSTATUS charset_ ## CHARSETNAME ## _init(void);							\
+NTSTATUS charset_ ## CHARSETNAME ## _init(void)							\
+{												\
+	return smb_register_charset(& CHARSETNAME ## _functions);				\
+}												\
+
+
 #endif /* __CHARSET_H__ */
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index b6842a4..98284ce 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -22,6 +22,7 @@
 #include "../lib/util/dlinklist.h"
 #include "system/iconv.h"
 #include "system/filesys.h"
+#undef strcasecmp
 
 
 /**
diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index fbe7b10..091876f 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -404,12 +404,12 @@ static bool test_string2key(struct torture_context *tctx)
 	uint16_t *buf;
 	char *dest = NULL;
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
-	ssize_t ret;
 	size_t len = (random()%1000)+1;
 	const uint16_t in1[10] = { 'a', 0xd805, 'b', 0xdcf0, 'c', 0, 'd', 'e', 'f', 'g' };
 	uint8_t le1[20];
 	uint8_t *munged1;
 	uint8_t *out1;
+	size_t ret;
 	int i;
 	const char *correct = "a\357\277\275b\357\277\275c\001defg";
 
@@ -418,8 +418,7 @@ static bool test_string2key(struct torture_context *tctx)
 
 	torture_comment(tctx, "converting random buffer\n");
 
-	ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest, false);
-	if (ret == -1) {
+	if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest, &ret, false)) {
 		torture_fail(tctx, "Failed to convert random buffer\n");
 	}
 
@@ -429,8 +428,7 @@ static bool test_string2key(struct torture_context *tctx)
 
 	torture_comment(tctx, "converting fixed buffer to UTF16\n");
 
-	ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1, false);
-	if (ret == -1) {
+	if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1, &ret, false)) {
 		torture_fail(tctx, "Failed to convert fixed buffer to UTF16_MUNGED\n");
 	}
 
@@ -438,8 +436,7 @@ static bool test_string2key(struct torture_context *tctx)
 
 	torture_comment(tctx, "converting fixed buffer to UTF8\n");
 
-	ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1, false);
-	if (ret == -1) {
+	if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1, &ret, false)) {
 		torture_fail(tctx, "Failed to convert fixed buffer to UTF8\n");
 	}
 
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index 96c9873..ec88e78 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -668,11 +668,11 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag
  * @returns The number of bytes occupied by the string in the destination
  *         or -1 in case of error.
  **/
-_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
 {
 	size_t src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, false);
+	return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, converted_size, false);
 }
 
 
@@ -779,11 +779,11 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags
  * @returns The number of bytes occupied by the string in the destination
  *         or -1 in case of error.
  **/
-_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
+_PUBLIC_ bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size)
 {
 	size_t src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, dest, false);
+	return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, (void **)dest, converted_size, false);
 }
 
 
@@ -795,11 +795,11 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
  * @returns The number of bytes occupied by the string in the destination
  **/
 
-_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
 {
 	size_t src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, false);
+	return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, converted_size, false);
 }
 
 /**
@@ -850,11 +850,11 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src
  * @returns The number of bytes occupied by the string in the destination
  **/
 
-_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
 {
 	size_t src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, false);
+	return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
 }
 
 /**
@@ -865,11 +865,11 @@ _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src
  * @returns The number of bytes occupied by the string in the destination
  **/
 
-_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
+_PUBLIC_ bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size)
 {
 	size_t src_len = utf16_len(src);
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, false);
+	return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
 }
 
 /**
@@ -880,11 +880,11 @@ _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
  * @returns The number of bytes occupied by the string in the destination
  **/
 
-_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
 {
 	size_t src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, false);
+	return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
 }
 
 /**
@@ -952,11 +952,16 @@ _PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_
  **/
 _PUBLIC_ size_t convert_string(charset_t from, charset_t to,
 				void const *src, size_t srclen, 
-				void *dest, size_t destlen, bool allow_badcharcnv)
+				void *dest, size_t destlen, 
+				bool allow_badcharcnv)
 {
-	return convert_string_convenience(get_iconv_convenience(), from, to, 
+	size_t ret;
+	if (!convert_string_convenience(get_iconv_convenience(), from, to, 
 									  src, srclen,
-									  dest, destlen, allow_badcharcnv);
+									  dest, destlen, &ret,
+									  allow_badcharcnv))
+		return -1;
+	return ret;
 }
 
 /**
@@ -964,18 +969,21 @@ _PUBLIC_ size_t convert_string(charset_t from, charset_t to,
  *
  * @param srclen length of source buffer.
  * @param dest always set at least to NULL
+ * @param converted_size Size in bytes of the converted string
  * @note -1 is not accepted for srclen.
  *
- * @returns Size in bytes of the converted string; or -1 in case of error.
+ * @returns boolean indication whether the conversion succeeded
  **/
 
-_PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, 
+_PUBLIC_ bool convert_string_talloc(TALLOC_CTX *ctx, 
 				       charset_t from, charset_t to, 
 				       void const *src, size_t srclen, 
-				       void **dest, bool allow_badcharcnv)
+				       void **dest, size_t *converted_size, 
+					   bool allow_badcharcnv)
 {
 	return convert_string_talloc_convenience(ctx, get_iconv_convenience(),
 											 from, to, src, srclen, dest,
+											 converted_size, 
 											 allow_badcharcnv);
 }
 
diff --git a/source3/Makefile.in b/source3/Makefile.in
index f127255..abf6cfb 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -366,8 +366,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
 	  lib/substitute.o lib/dbwrap_util.o \
 	  lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
 	  lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
-	  lib/iconv.o lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \
-	  lib/adt_tree.o lib/gencache.o \
+	  ../lib/util/charset/iconv.o lib/pam_errors.o intl/lang_tdb.o \
+	  lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \


-- 
Samba Shared Repository


More information about the samba-cvs mailing list