[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre3-64-gde66f05

Karolin Seeger kseeger at samba.org
Wed May 7 14:29:37 GMT 2008


The branch, v3-2-stable has been updated
       via  de66f050e31e069dfe76644eacfdfd56cc5d179d (commit)
       via  2db1b02c57bdce0d24a2acfa486862046f33bfa5 (commit)
       via  93ac0f0ea989af4cdbcba740fddc2e0e423f37cd (commit)
       via  e1210bcd54525737296d2d7e4b3e6f4c332376f7 (commit)
       via  341544230f7f8415140cee95ed2066f49f609aae (commit)
       via  76c2fd6a6bc606a796995ac7c027f2e39dc70e3e (commit)
       via  a8f256ee8e5eefea3ac930400d9f2865ce1131db (commit)
       via  873dfeaf397dde0a3198e914f239f50f91240cf1 (commit)
       via  27cb294644745635689049e07f7b99f9c34e2ebc (commit)
       via  66a06bdd4d815e8b287e952ae5f25b1bfa2089f7 (commit)
       via  2fa1f44172d03d1503123ae313f73645950575c2 (commit)
      from  6062c6eedcb1cccb103c44a2ff7f40e9eac87cb6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit de66f050e31e069dfe76644eacfdfd56cc5d179d
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 11 14:19:28 2008 +0100

    Remove redundant parameter fd from SMB_VFS_CLOSE().
    
    Now all those redundant fd's have vanished from the VFS API.
    
    Michael
    (cherry picked from commit 14294535512a7f191c5008e622b6708e417854ae)

commit 2db1b02c57bdce0d24a2acfa486862046f33bfa5
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 11 13:41:46 2008 +0100

    Slight reformatting of fd_close_posix(), while I'm at it.
    
    Wrap lines and remove trailing space.
    
    Michael
    (cherry picked from commit 74ed53a115b2063d4d5c8572af8f1302bc658882)

commit 93ac0f0ea989af4cdbcba740fddc2e0e423f37cd
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 11 13:28:28 2008 +0100

    Change fd_close_posix() to return int instead of NTSTATUS.
    
    The errno is handed up through the VFS layer to the callers.
    
    Michael
    (cherry picked from commit d928e6648d61cf2d3c1b77db440efb835b729a84)

commit e1210bcd54525737296d2d7e4b3e6f4c332376f7
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 11 13:03:16 2008 +0100

    Don't modify the fsp in fd_close_posix() anymore.
    
    Now that it is inside the vfs layer, this function should
    not alter the fsp (i.e. set fsp->fh->fd = -1) anymore.
    That belongs above the vfs layer.
    
    Michael
    (cherry picked from commit df264bf3e00d7d77afcf55e54d2669b9ffa9af4a)

commit 341544230f7f8415140cee95ed2066f49f609aae
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 11 12:18:33 2008 +0100

    Move the posix pending close functionality down into the VFS layer.
    
    This hides the pending close fds from the outside. Call order
    of SMB_VFS_CLOSE is reversed. Originally, it was:
    
    fd_close -> fd_close_posix -> SMB_VFS_CLOSE -> close
    
    And now it is:
    
    fd_close -> SMB_VFS_CLOSE -> fd_close_posix -> close
    
    This is in preparation of removing the fd parameter
    from the SMB_VFS_CLOSE function. But it is also the right
    place for the pending close calls anyways.
    
    Michael
    (cherry picked from commit 3cf56b124a2886c6260455bba4bf77d08e9a4f77)

commit 76c2fd6a6bc606a796995ac7c027f2e39dc70e3e
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 27 12:16:23 2008 +0200

    Next round fixing bug 5420, build on IRIX
    
    The IRIX make does not like lines with only whitespace. With LIBNETAPI_LIBS
    evaluating to nothing this happens there.
    (cherry picked from commit 2883e554f45ca01dbfc205baa0b4149d2f2a01e8)

commit a8f256ee8e5eefea3ac930400d9f2865ce1131db
Author: Günther Deschner <gd at samba.org>
Date:   Wed Apr 30 18:23:26 2008 +0200

    pam_winbind: Fix Bug #5430 (patch from fumiyas at osstech.co.jp).
    
    Guenther
    (cherry picked from commit 5b65df6245c1458ca21cc602df11c49aa97a25c5)
    (cherry picked from commit 06f33d3725e0d82568c4a3278f59892e3e57a8ee)

commit 873dfeaf397dde0a3198e914f239f50f91240cf1
Author: Gerald W. Carter <jerry at samba.org>
Date:   Wed Apr 30 09:57:15 2008 -0500

    BUG 5107: Fix handling of large DNS replies on AIX and Solaris.
    
    On AIX, Solaris, and possibly some older glibc systems (e.g. SLES8)
    truncated replies never give back a resp_len > buflen
    which ends up causing DNS resolve failures on large tcp DNS replies.
    
    Also add more debug lines about processing the DNS reply.
    (cherry picked from commit 5ed9b92097460cd8180db806a08213e97cfb8daa)
    (cherry picked from commit 5dff914f9ebcda63b9e3c78d6d0bb5a3212c6690)

commit 27cb294644745635689049e07f7b99f9c34e2ebc
Author: Gerald W. Carter <jerry at samba.org>
Date:   Wed Apr 30 09:43:00 2008 -0500

    BUG 5429: Clarify log msgs re: failure to create BUILTIN\{Administrators,Users}
    
    Raise the debug msgs from Lvl 0 in the create_builtin_XX() functions
    to prevent unnecessary panic from people reading the logs.
    (cherry picked from commit 2983b9dc790e0f90ec1e6add131438c6bfd361b4)
    (cherry picked from commit c28e21c63eca87a266078b65d65b436badc4e349)

commit 66a06bdd4d815e8b287e952ae5f25b1bfa2089f7
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 28 15:06:14 2008 -0700

    Fix bug found by Igor Mammedov <niallain at gmail.com> where we are
    not returning a directory value for a QPATHINFO on a msdfs link
    with a non-dfs path. Windows does this.
    Jeremy.
    (cherry picked from commit 1b2f189e1f78a52a4d1e224bb5d20d77bb192d56)

commit 2fa1f44172d03d1503123ae313f73645950575c2
Author: Tim Prouty <tim.prouty at isilon.com>
Date:   Mon Mar 3 13:32:54 2008 -0800

    Cleanup size_t return values in convert_string_allocate
    
    This patch is the first iteration of an inside-out conversion to cleanup
    functions in charcnv.c returning size_t == -1 to indicate failure.
    (cherry picked from commit 59124382d2894a1b194b48dd82bc5f956959eb48)

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

Summary of changes:
 examples/VFS/skel_opaque.c           |    4 +-
 examples/VFS/skel_transparent.c      |    4 +-
 source/Makefile.in                   |    5 +-
 source/auth/token_util.c             |   16 ++--
 source/configure.in                  |    2 +
 source/include/vfs.h                 |    3 +-
 source/include/vfs_macros.h          |    6 +-
 source/lib/charcnv.c                 |  134 +++++++++++++++++++---------------
 source/lib/util_reg.c                |    6 +-
 source/libads/dns.c                  |   38 ++++++++--
 source/libsmb/climessage.c           |    5 +-
 source/locking/posix.c               |   36 ++++------
 source/modules/vfs_audit.c           |    8 +-
 source/modules/vfs_commit.c          |    5 +-
 source/modules/vfs_default.c         |    5 +-
 source/modules/vfs_extd_audit.c      |   10 +-
 source/modules/vfs_full_audit.c      |    6 +-
 source/modules/vfs_streams_xattr.c   |    2 +-
 source/modules/vfs_syncops.c         |    6 +-
 source/smbd/notify.c                 |    7 +-
 source/smbd/open.c                   |   10 ++-
 source/smbd/trans2.c                 |   56 +++++++++++----
 source/torture/cmd_vfs.c             |    2 +-
 source/utils/ntlm_auth_diagnostics.c |    7 +-
 source/web/cgi.c                     |    8 +-
 25 files changed, 231 insertions(+), 160 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 4a6e6be..eb49f35 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -125,9 +125,9 @@ static int skel_open(vfs_handle_struct *handle,  const char *fname, files_struct
 	return vfswrap_open(NULL,  fname, flags, mode);
 }
 
-static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_close(vfs_handle_struct *handle, files_struct *fsp)
 {
-	return vfswrap_close(NULL, fsp, fd);
+	return vfswrap_close(NULL, fsp);
 }
 
 static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index f4cb9b1..7102d4d 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -119,9 +119,9 @@ static int skel_open(vfs_handle_struct *handle,  const char *fname, files_struct
 	return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
 }
 
-static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_close(vfs_handle_struct *handle, files_struct *fsp)
 {
-	return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+	return SMB_VFS_NEXT_CLOSE(handle, fsp);
 }
 
 static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
diff --git a/source/Makefile.in b/source/Makefile.in
index 5b2966a..95e96d5 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -1339,8 +1339,7 @@ bin/net at EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @L
 	@$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \
 		@POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \
 		$(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \
-		@INIPARSERLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ \
-		@LIBNETAPI_LIBS@
+		@INIPARSERLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@
 
 bin/profiles at EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@
 	@echo Linking $@
@@ -1758,7 +1757,7 @@ bin/winbind_krb5_locator. at SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OB
 bin/pam_winbind. at SHLIBEXT@: $(BINARY_PREREQS) $(PAM_WINBIND_OBJ)
 	@echo "Linking shared library $@"
 	@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_WINBIND_OBJ) -lpam @INIPARSERLIBS@ \
-		@SONAMEFLAG@`basename $@`
+		@PAM_WINBIND_EXTRA_LIBS@ @SONAMEFLAG@`basename $@`
 
 bin/builtin. at SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_BUILTIN_OBJ)
 	@echo "Building plugin $@"
diff --git a/source/auth/token_util.c b/source/auth/token_util.c
index 6720a2c..cd67c2a 100644
--- a/source/auth/token_util.c
+++ b/source/auth/token_util.c
@@ -210,7 +210,7 @@ static NTSTATUS create_builtin_users( void )
 
 	status = pdb_create_builtin_alias( BUILTIN_ALIAS_RID_USERS );
 	if ( !NT_STATUS_IS_OK(status) ) {
-		DEBUG(0,("create_builtin_users: Failed to create Users\n"));
+		DEBUG(5,("create_builtin_users: Failed to create Users\n"));
 		return status;
 	}
 
@@ -221,7 +221,7 @@ static NTSTATUS create_builtin_users( void )
 		sid_append_rid(&dom_users, DOMAIN_GROUP_RID_USERS );
 		status = pdb_add_aliasmem( &global_sid_Builtin_Users, &dom_users);
 		if ( !NT_STATUS_IS_OK(status) ) {
-			DEBUG(0,("create_builtin_administrators: Failed to add Domain Users to"
+			DEBUG(4,("create_builtin_administrators: Failed to add Domain Users to"
 				" Users\n"));
 			return status;
 		}
@@ -244,7 +244,7 @@ static NTSTATUS create_builtin_administrators( void )
 
 	status = pdb_create_builtin_alias( BUILTIN_ALIAS_RID_ADMINS );
 	if ( !NT_STATUS_IS_OK(status) ) {
-		DEBUG(0,("create_builtin_administrators: Failed to create Administrators\n"));
+		DEBUG(5,("create_builtin_administrators: Failed to create Administrators\n"));
 		return status;
 	}
 
@@ -255,7 +255,7 @@ static NTSTATUS create_builtin_administrators( void )
 		sid_append_rid(&dom_admins, DOMAIN_GROUP_RID_ADMINS);
 		status = pdb_add_aliasmem( &global_sid_Builtin_Administrators, &dom_admins );
 		if ( !NT_STATUS_IS_OK(status) ) {
-			DEBUG(0,("create_builtin_administrators: Failed to add Domain Admins"
+			DEBUG(4,("create_builtin_administrators: Failed to add Domain Admins"
 				" Administrators\n"));
 			return status;
 		}
@@ -273,7 +273,7 @@ static NTSTATUS create_builtin_administrators( void )
 	if ( ret ) {
 		status = pdb_add_aliasmem( &global_sid_Builtin_Administrators, &root_sid );
 		if ( !NT_STATUS_IS_OK(status) ) {
-			DEBUG(0,("create_builtin_administrators: Failed to add root"
+			DEBUG(4,("create_builtin_administrators: Failed to add root"
 				" Administrators\n"));
 			return status;
 		}
@@ -381,7 +381,8 @@ struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
 			become_root();
 			status = create_builtin_administrators( );
 			if ( !NT_STATUS_IS_OK(status) ) {
-				DEBUG(2,("create_local_nt_token: Failed to create BUILTIN\\Administrators group!\n"));
+				DEBUG(2,("WARNING: Failed to create BUILTIN\\Administrators "
+					 "group!  Can Winbind allocate gids?\n"));
 				/* don't fail, just log the message */
 			}
 			unbecome_root();
@@ -408,7 +409,8 @@ struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
 			become_root();
 			status = create_builtin_users( );
 			if ( !NT_STATUS_IS_OK(status) ) {
-				DEBUG(2,("create_local_nt_token: Failed to create BUILTIN\\Users group!\n"));
+				DEBUG(2,("WARNING: Failed to create BUILTIN\\Users group! "
+					 "Can Winbind allocate gids?\n"));
 				/* don't fail, just log the message */
 			}
 			unbecome_root();
diff --git a/source/configure.in b/source/configure.in
index 52e4b50..ef39d6b 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -5701,6 +5701,7 @@ case "$host_os" in
 		WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
 		    nsswitch/winbind_nss_linux.o"
 		WINBIND_NSS_EXTRA_LIBS="-lsocket"
+		PAM_WINBIND_EXTRA_LIBS="-lsocket"
 		;;
 	*hpux11*)
 		WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
@@ -5795,6 +5796,7 @@ AC_SUBST(WINBIND_NSS_LDSHFLAGS)
 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
+AC_SUBST(PAM_WINBIND_EXTRA_LIBS)
 
 AC_SUBST(WINBIND_KRB5_LOCATOR)
 
diff --git a/source/include/vfs.h b/source/include/vfs.h
index ca176aa..c839716 100644
--- a/source/include/vfs.h
+++ b/source/include/vfs.h
@@ -105,6 +105,7 @@
 /* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
 /* Leave at 22 - not yet released. Additional change: add operations for offline files -- ab */
 /* Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl */
+/* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox */
 
 #define SMB_VFS_INTERFACE_VERSION 22
 
@@ -301,7 +302,7 @@ struct vfs_ops {
 		/* File operations */
 
 		int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
-		int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd);
+		int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
 		ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
 		ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
 		ssize_t (*write)(struct vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n);
diff --git a/source/include/vfs_macros.h b/source/include/vfs_macros.h
index 1e64bd5..f0a9809 100644
--- a/source/include/vfs_macros.h
+++ b/source/include/vfs_macros.h
@@ -48,7 +48,7 @@
 
 /* File operations */
 #define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_CLOSE(fsp, fd) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_CLOSE(fsp) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp)))
 #define SMB_VFS_READ(fsp, data, n) ((fsp)->conn->vfs.ops.read((fsp)->conn->vfs.handles.read, (fsp), (data), (n)))
 #define SMB_VFS_PREAD(fsp, data, n, off) ((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (data), (n), (off)))
 #define SMB_VFS_WRITE(fsp, data, n) ((fsp)->conn->vfs.ops.write((fsp)->conn->vfs.handles.write, (fsp), (data), (n)))
@@ -174,7 +174,7 @@
 
 /* File operations */
 #define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_OPAQUE_CLOSE(fsp) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp)))
 #define SMB_VFS_OPAQUE_READ(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.read((fsp)->conn->vfs_opaque.handles.read, (fsp), (data), (n)))
 #define SMB_VFS_OPAQUE_PREAD(fsp, data, n, off) ((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, (fsp), (data), (n), (off)))
 #define SMB_VFS_OPAQUE_WRITE(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.write((fsp)->conn->vfs_opaque.handles.write, (fsp), (data), (n)))
@@ -301,7 +301,7 @@
 
 /* File operations */
 #define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) (((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
-#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), (fd)))
+#define SMB_VFS_NEXT_CLOSE(handle, fsp) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp)))
 #define SMB_VFS_NEXT_READ(handle, fsp, data, n) ((handle)->vfs_next.ops.read((handle)->vfs_next.handles.read, (fsp), (data), (n)))
 #define SMB_VFS_NEXT_PREAD(handle, fsp, data, n, off) ((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (data), (n), (off)))
 #define SMB_VFS_NEXT_WRITE(handle, fsp, data, n) ((handle)->vfs_next.ops.write((handle)->vfs_next.handles.write, (fsp), (data), (n)))
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index 69d1db0..81b7238 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -511,9 +511,12 @@ size_t convert_string(charset_t from, charset_t to,
  * (this is a bad interface and needs fixing. JRA).
  * @param srclen length of source buffer.
  * @param dest always set at least to NULL
+ * @param converted_size set to the size of the allocated buffer on return
+ * true
  * @note -1 is not accepted for srclen.
  *
- * @returns Size in bytes of the converted string; or -1 in case of error.
+ * @return True if new buffer was correctly allocated, and string was
+ * converted.
  *
  * Ensure the srclen contains the terminating zero.
  *
@@ -521,8 +524,9 @@ size_t convert_string(charset_t from, charset_t to,
  * There has to be a cleaner way to do this. JRA.
  **/
 
-size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
-			       void const *src, size_t srclen, void *dst, bool allow_bad_conv)
+bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
+			     void const *src, size_t srclen, void *dst,
+			     size_t *converted_size, bool allow_bad_conv)
 {
 	size_t i_len, o_len, destlen = (srclen * 3) / 2;
 	size_t retval;
@@ -533,10 +537,19 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 
 	*dest = NULL;
 
-	if (src == NULL || srclen == (size_t)-1)
-		return (size_t)-1;
-	if (srclen == 0)
-		return 0;
+	if (!converted_size) {
+		errno = EINVAL;
+		return false;
+	}
+
+	if (src == NULL || srclen == (size_t)-1) {
+		errno = EINVAL;
+		return false;
+	}
+	if (srclen == 0) {
+		*converted_size = 0;
+		return true;
+	}
 
 	lazy_initialize_conv();
 
@@ -545,7 +558,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 	if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
 		if (!conv_silent)
 			DEBUG(0,("convert_string_allocate: Conversion not supported.\n"));
-		return (size_t)-1;
+		errno = EOPNOTSUPP;
+		return false;
 	}
 
   convert:
@@ -557,7 +571,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 			DEBUG(0, ("convert_string_allocate: destlen wrapped !\n"));
 		if (!ctx)
 			SAFE_FREE(outbuf);
-		return (size_t)-1;
+		errno = EOPNOTSUPP;
+		return false;
 	} else {
 		destlen = destlen * 2;
 	}
@@ -571,7 +586,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 
 	if (!ob) {
 		DEBUG(0, ("convert_string_allocate: realloc failed!\n"));
-		return (size_t)-1;
+		errno = ENOMEM;
+		return false;
 	}
 	outbuf = ob;
 	i_len = srclen;
@@ -610,7 +626,7 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 		} else {
 			SAFE_FREE(ob);
 		}
-		return (size_t)-1;
+		return false;
 	}
 
   out:
@@ -631,7 +647,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 
 	if (destlen && !ob) {
 		DEBUG(0, ("convert_string_allocate: out of memory!\n"));
-		return (size_t)-1;
+		errno = ENOMEM;
+		return false;
 	}
 
 	*dest = ob;
@@ -640,7 +657,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
 	ob[destlen] = '\0';
 	ob[destlen+1] = '\0';
 
-	return destlen;
+	*converted_size = destlen;
+	return true;
 
  use_as_is:
 
@@ -743,8 +761,8 @@ size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
 	size_t dest_len;
 
 	*dest = NULL;
-	dest_len=convert_string_allocate(ctx, from, to, src, srclen, dest, allow_bad_conv);
-	if (dest_len == (size_t)-1)
+	if (!convert_string_allocate(ctx, from, to, src, srclen, dest,
+		&dest_len, allow_bad_conv))
 		return (size_t)-1;
 	if (*dest == NULL)
 		return (size_t)-1;
@@ -798,39 +816,28 @@ char *strdup_upper(const char *s)
 
 	if (*p) {
 		/* MB case. */
-		size_t size;
+		size_t size, size2;
 		smb_ucs2_t *buffer = NULL;
 
 		SAFE_FREE(out_buffer);
-		size = convert_string_allocate(NULL,
-					CH_UNIX,
-					CH_UTF16LE,
-					s,
-					strlen(s) + 1,
-					(void **)(void *)&buffer,
-					True);
-		if (size == (size_t)-1) {
+		if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, s,
+			strlen(s) + 1, (void **)(void *)&buffer, &size,
+			True)) {
 			return NULL;
 		}
 
 		strupper_w(buffer);
 
-		size = convert_string_allocate(NULL,
-					CH_UTF16LE,
-					CH_UNIX,
-					buffer,
-					size,
-					(void **)(void *)&out_buffer,
-					True);
+		if (!convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, buffer,
+			size, (void **)(void *)&out_buffer, &size2, True)) {
+			TALLOC_FREE(buffer);
+			return NULL;
+		}
 
 		/* Don't need the intermediate buffer
  		 * anymore.
  		 */
-
 		TALLOC_FREE(buffer);
-		if (size == (size_t)-1) {
-			return NULL;
-		}
 	}
 
 	return out_buffer;
@@ -904,9 +911,8 @@ size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen)
 	size_t size;
 	smb_ucs2_t *buffer = NULL;
 
-	size = convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
-				       (void **)(void *)&buffer, True);
-	if (size == (size_t)-1 || !buffer) {
+	if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
+		(void **)(void *)&buffer, &size, True)) {
 		smb_panic("failed to create UCS2 buffer");
 	}
 	if (!strlower_w(buffer) && (dest == src)) {
@@ -1077,10 +1083,14 @@ size_t push_ascii_nstring(void *dest, const char *src)
 
 size_t push_ascii_allocate(char **dest, const char *src)
 {
-	size_t src_len = strlen(src)+1;
+	size_t dest_len, src_len = strlen(src)+1;
 
 	*dest = NULL;
-	return convert_string_allocate(NULL, CH_UNIX, CH_DOS, src, src_len, (void **)dest, True);
+	if (!convert_string_allocate(NULL, CH_UNIX, CH_DOS, src, src_len,
+		(void **)dest, &dest_len, True))
+		return (size_t)-1;
+	else
+		return dest_len;
 }
 
 /**
@@ -1192,17 +1202,9 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
 		}
 	}
 
-	dest_len = convert_string_allocate(ctx,
-				CH_DOS,
-				CH_UNIX,
-				src,
-				src_len,
-				&dest,
-				True);
-
-	if (dest_len == (size_t)-1) {
+	if (!convert_string_allocate(ctx, CH_DOS, CH_UNIX, src, src_len, &dest,
+		&dest_len, True))
 		dest_len = 0;
-	}
 
 	if (dest_len && dest) {
 		/* Did we already process the terminating zero ? */
@@ -1333,10 +1335,14 @@ size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
 
 size_t push_ucs2_allocate(smb_ucs2_t **dest, const char *src)
 {
-	size_t src_len = strlen(src)+1;
+	size_t dest_len, src_len = strlen(src)+1;
 
 	*dest = NULL;
-	return convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, src_len, (void **)dest, True);
+	if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, src_len,
+		(void **)dest, &dest_len, True))
+		return (size_t)-1;
+	else
+		return dest_len;
 }
 
 /**
@@ -1410,10 +1416,14 @@ size_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
 
 size_t push_utf8_allocate(char **dest, const char *src)
 {
-	size_t src_len = strlen(src)+1;
+	size_t dest_len, src_len = strlen(src)+1;
 
 	*dest = NULL;
-	return convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, True);	
+	if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len,
+		(void **)dest, &dest_len, True))
+		return (size_t)-1;
+	else
+		return dest_len;
 }
 
 /**
@@ -1625,9 +1635,13 @@ size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
 
 size_t pull_ucs2_allocate(char **dest, const smb_ucs2_t *src)
 {
-	size_t src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
+	size_t dest_len, src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
 	*dest = NULL;
-	return convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, src, src_len, (void **)dest, True);
+	if (!convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, src, src_len,
+		(void **)dest, &dest_len, True))
+		return (size_t)-1;
+	else
+		return dest_len;
 }
 
 /**
@@ -1655,9 +1669,13 @@ size_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
 
 size_t pull_utf8_allocate(char **dest, const char *src)
 {
-	size_t src_len = strlen(src)+1;
+	size_t dest_len, src_len = strlen(src)+1;
 	*dest = NULL;
-	return convert_string_allocate(NULL, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, True);
+	if (!convert_string_allocate(NULL, CH_UTF8, CH_UNIX, src, src_len,
+		(void **)dest, &dest_len, True))
+		return (size_t)-1;
+	else
+		return dest_len;
 }
  
 /**
diff --git a/source/lib/util_reg.c b/source/lib/util_reg.c
index 2db5c7b..6570bb0 100644
--- a/source/lib/util_reg.c
+++ b/source/lib/util_reg.c
@@ -93,10 +93,8 @@ WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
 		size_t dstlen, thislen;
 
 		thislen = strnlen_w(p, len) + 1;
-		dstlen = convert_string_allocate(*values, CH_UTF16LE, CH_UNIX,
-						 p, thislen*2, (void *)&val,
-						 true);
-		if (dstlen == (size_t)-1) {
+		if (!convert_string_allocate(*values, CH_UTF16LE, CH_UNIX,
+			p, thislen*2, (void *)&val, &dstlen, true)) {
 			TALLOC_FREE(*values);
 			return WERR_NOMEM;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list