[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Aug 9 15:53:02 MDT 2012


The branch, master has been updated
       via  a5495bc Remove smb_panic() from unix_strlower(). Just rely on error code return.
       via  b70f23c Correctly check for errors in strlower_m() returns.
       via  ce21d08 Fix strlower_m() to return an error indication.
       via  c13887d Check error returns on strnorm().
       via  526e875 Check error returns from strupper_m() (in all reasonable places).
       via  e1ec86a Fix missing ads_destroy in error path.
       via  9fcc6f2 Change strupper_m() to return a value.
       via  af3e529 Fix bad return in unix_strupper.
       via  b6eb3a6 Prepare to remove smb_panic() from unix_strlower().
       via  8605b35 Fix bad return values in unix_strlower/unix_strupper.
      from  f64c970 s4:torture:basic: check the return status of the last open in deltest16

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


- Log -----------------------------------------------------------------
commit a5495bc6b073d29041d9a8e229d37693d6a0c513
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 17:32:50 2012 -0700

    Remove smb_panic() from unix_strlower(). Just rely on error code return.
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug  9 23:52:53 CEST 2012 on sn-devel-104

commit b70f23c2b581c5d455362ab37f4846de9a910055
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 17:01:00 2012 -0700

    Correctly check for errors in strlower_m() returns.

commit ce21d0804012da27cec72abe896352d7f0e7e1e5
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 15:56:58 2012 -0700

    Fix strlower_m() to return an error indication.

commit c13887defc4c05b6b87f8f40ae0cf981a497f443
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 15:49:34 2012 -0700

    Check error returns on strnorm().

commit 526e875cec15761099438e17df3f56bc2bd5b761
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 15:35:28 2012 -0700

    Check error returns from strupper_m() (in all reasonable places).

commit e1ec86a49ce1d7c3ebe99fc175ffad70a03c4a0b
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 15:21:33 2012 -0700

    Fix missing ads_destroy in error path.

commit 9fcc6f27fb2cf8cf5c30b701cb6788fc8f70cf82
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 12:16:40 2012 -0700

    Change strupper_m() to return a value.

commit af3e529c18dae94d10b617eb8377e2ab64d34982
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 12:10:01 2012 -0700

    Fix bad return in unix_strupper.

commit b6eb3a68088a20fba4819064699abdddfd594a4d
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 12:07:54 2012 -0700

    Prepare to remove smb_panic() from unix_strlower().

commit 8605b35e8824bf30633d47333df3720f9ff4dbaa
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 8 12:06:34 2012 -0700

    Fix bad return values in unix_strlower/unix_strupper.

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

Summary of changes:
 libgpo/gpext/gpext.c                        |    4 ++-
 source3/auth/auth_builtin.c                 |    8 +++-
 source3/auth/auth_util.c                    |    4 ++-
 source3/auth/pampass.c                      |    4 +-
 source3/auth/pass_check.c                   |    8 +++-
 source3/auth/user_util.c                    |    4 ++-
 source3/client/client.c                     |    9 ++++-
 source3/client/clitar.c                     |    2 +-
 source3/include/proto.h                     |    6 ++--
 source3/lib/afs.c                           |    4 ++-
 source3/lib/charcnv.c                       |    5 ++-
 source3/lib/substitute.c                    |   15 ++++++--
 source3/lib/username.c                      |   16 +++++++--
 source3/lib/util.c                          |   10 ++++-
 source3/lib/util_names.c                    |    3 +-
 source3/lib/util_str.c                      |   52 +++++++++++++++++---------
 source3/libads/ads_struct.c                 |    6 +++-
 source3/libads/kerberos.c                   |    6 ++-
 source3/libads/kerberos_keytab.c            |    5 ++-
 source3/libads/ldap.c                       |   33 ++++++++++++++---
 source3/libads/sasl.c                       |   27 ++++++++++++--
 source3/libnet/libnet_join.c                |   27 +++++++++++---
 source3/librpc/crypto/gse_krb5.c            |    5 ++-
 source3/libsmb/cliconnect.c                 |    4 ++-
 source3/libsmb/clirap.c                     |    8 +++-
 source3/libsmb/clirap2.c                    |    8 +++-
 source3/libsmb/namequery_dc.c               |    6 +++-
 source3/libsmb/nmblib.c                     |    6 ++-
 source3/modules/vfs_afsacl.c                |    4 ++-
 source3/modules/vfs_prealloc.c              |    4 ++-
 source3/modules/vfs_streams_depot.c         |    5 ++-
 source3/modules/vfs_streams_xattr.c         |    4 ++-
 source3/nmbd/nmbd_browserdb.c               |   10 ++++-
 source3/nmbd/nmbd_browsesync.c              |    5 ++-
 source3/nmbd/nmbd_elections.c               |    5 ++-
 source3/nmbd/nmbd_incomingdgrams.c          |    5 ++-
 source3/nmbd/nmbd_incomingrequests.c        |    5 ++-
 source3/nmbd/nmbd_namelistdb.c              |   21 ++++++++---
 source3/nmbd/nmbd_sendannounce.c            |   10 ++++-
 source3/nmbd/nmbd_serverlistdb.c            |    6 +++-
 source3/nmbd/nmbd_winsserver.c              |    2 +-
 source3/param/loadparm.c                    |    5 ++-
 source3/param/service.c                     |    4 ++-
 source3/passdb/lookup_sid.c                 |    5 ++-
 source3/passdb/machine_account_secrets.c    |    8 +++-
 source3/passdb/pdb_interface.c              |    8 +++-
 source3/passdb/pdb_ipa.c                    |    4 ++-
 source3/passdb/pdb_ldap.c                   |    9 ++++-
 source3/passdb/pdb_tdb.c                    |   28 +++++++++++----
 source3/printing/lpq_parse.c                |    4 ++-
 source3/printing/nt_printing_tdb.c          |    4 +-
 source3/registry/reg_backend_db.c           |    4 ++-
 source3/registry/reg_util_internal.c        |    5 ++-
 source3/rpc_server/dfs/srv_dfs_nt.c         |    4 ++-
 source3/rpc_server/dssetup/srv_dssetup_nt.c |    4 ++-
 source3/smbd/filename.c                     |   15 ++++++--
 source3/smbd/lanman.c                       |   14 +++++--
 source3/smbd/mangle_hash.c                  |    5 ++-
 source3/smbd/mangle_hash2.c                 |    2 +-
 source3/smbd/negprot.c                      |    2 +-
 source3/smbd/service.c                      |   11 +++++-
 source3/smbd/smb2_tcon.c                    |    5 ++-
 source3/torture/masktest.c                  |    4 +-
 source3/torture/torture.c                   |    2 +-
 source3/utils/net_ads.c                     |   20 ++++++++--
 source3/utils/net_idmap.c                   |    6 +++-
 source3/utils/net_registry_check.c          |   10 ++++-
 source3/utils/net_rpc.c                     |   38 ++++++++++++++++----
 source3/utils/net_rpc_join.c                |   10 ++++-
 source3/utils/net_usershare.c               |    8 +++-
 source3/utils/ntlm_auth.c                   |    4 +--
 source3/utils/pdbedit.c                     |   11 +++++-
 source3/utils/smbcontrol.c                  |    2 +-
 source3/utils/smbpasswd.c                   |    6 +++-
 source3/winbindd/idmap_ldap.c               |    7 +++-
 source3/winbindd/wb_fill_pwent.c            |    5 ++-
 source3/winbindd/winbindd_ads.c             |   10 ++++-
 source3/winbindd/winbindd_cache.c           |   22 ++++++++----
 source3/winbindd/winbindd_cm.c              |    5 ++-
 source3/winbindd/winbindd_pam.c             |   12 +++++--
 source3/winbindd/winbindd_util.c            |   11 +++---
 81 files changed, 546 insertions(+), 178 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libgpo/gpext/gpext.c b/libgpo/gpext/gpext.c
index 8bda729..df84475 100644
--- a/libgpo/gpext/gpext.c
+++ b/libgpo/gpext/gpext.c
@@ -440,7 +440,9 @@ static WERROR gp_extension_store_reg_entry(TALLOC_CTX *mem_ctx,
 	subkeyname = GUID_string2(mem_ctx, &entry->guid);
 	W_ERROR_HAVE_NO_MEMORY(subkeyname);
 
-	strupper_m(discard_const_p(char, subkeyname));
+	if (!strupper_m(discard_const_p(char, subkeyname))) {
+		return WERR_INVALID_PARAM;
+	}
 
 	werr = gp_store_reg_subkey(mem_ctx,
 				   subkeyname,
diff --git a/source3/auth/auth_builtin.c b/source3/auth/auth_builtin.c
index b757894..dce58bf 100644
--- a/source3/auth/auth_builtin.c
+++ b/source3/auth/auth_builtin.c
@@ -97,11 +97,15 @@ static NTSTATUS check_name_to_ntstatus_security(const struct auth_context *auth_
 	fstrcpy(user, user_info->client.account_name);
 
 	if (strnequal("NT_STATUS", user, strlen("NT_STATUS"))) {
-		strupper_m(user);
+		if (!strupper_m(user)) {
+			return NT_STATUS_INVALID_PARAMETER;
+		}
 		return nt_status_string_to_code(user);
 	}
 
-	strlower_m(user);
+	if (!strlower_m(user)) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
 	error_num = strtoul(user, NULL, 16);
 
 	DEBUG(5,("check_name_to_ntstatus_security: Error for user %s was %lx\n", user, error_num));
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 28d934a..a08d094 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -1252,7 +1252,9 @@ static NTSTATUS check_account(TALLOC_CTX *mem_ctx, const char *domain,
 	if (!lower_username) {
 		return NT_STATUS_NO_MEMORY;
 	}
-	strlower_m( lower_username );
+	if (!strlower_m( lower_username )) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
 
 	orig_dom_user = talloc_asprintf(mem_ctx,
 				"%s%c%s",
diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c
index 87fa8ca..427c22a 100644
--- a/source3/auth/pampass.c
+++ b/source3/auth/pampass.c
@@ -249,7 +249,7 @@ static struct chat_struct *make_pw_chat(const char *p)
 
 		special_char_sub(prompt);
 		fstrcpy(t->prompt, prompt);
-		strlower_m(t->prompt);
+		(void)strlower_m(t->prompt);
 		trim_char(t->prompt, ' ', ' ');
 
 		if (!next_token_talloc(frame, &p, &reply, NULL)) {
@@ -262,7 +262,7 @@ static struct chat_struct *make_pw_chat(const char *p)
 
 		special_char_sub(reply);
 		fstrcpy(t->reply, reply);
-		strlower_m(t->reply);
+		(void)strlower_m(t->reply);
 		trim_char(t->reply, ' ', ' ');
 
 	}
diff --git a/source3/auth/pass_check.c b/source3/auth/pass_check.c
index ca99261..f2d1fc2 100644
--- a/source3/auth/pass_check.c
+++ b/source3/auth/pass_check.c
@@ -867,7 +867,9 @@ NTSTATUS pass_check(const struct passwd *pass,
 
 	/* try all lowercase if it's currently all uppercase */
 	if (strhasupper(pass2)) {
-		strlower_m(pass2);
+		if (!strlower_m(pass2)) {
+			return NT_STATUS_INVALID_PARAMETER;
+		}
 		nt_status = password_check(pass2, (const void *)rhost);
 		if (NT_STATUS_IS_OK(nt_status)) {
 			return (nt_status);
@@ -880,7 +882,9 @@ NTSTATUS pass_check(const struct passwd *pass,
 	}
 
 	/* last chance - all combinations of up to level chars upper! */
-	strlower_m(pass2);
+	if (!strlower_m(pass2)) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
 
 	nt_status = string_combinations(pass2, password_check, level,
 					(const void *)rhost);
diff --git a/source3/auth/user_util.c b/source3/auth/user_util.c
index 8938aeb..4842192 100644
--- a/source3/auth/user_util.c
+++ b/source3/auth/user_util.c
@@ -164,7 +164,9 @@ bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname)
 	if (!lowercase_user) {
 		return false;
 	}
-	strlower_m(lowercase_user);
+	if (!strlower_m(lowercase_user)) {
+		return false;
+	}
 
 	if (strcmp(user,lowercase_user) == 0) {
 		/* user name was already lower case! */
diff --git a/source3/client/client.c b/source3/client/client.c
index 28fc30a..2c949ac 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1086,7 +1086,10 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 	}
 
 	if (lowercase) {
-		strlower_m(lname);
+		if (!strlower_m(lname)) {
+			d_printf("strlower_m %s failed\n", lname);
+			return 1;
+		}
 	}
 
 	status = cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli,
@@ -1296,7 +1299,9 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
 
 	string_replace(finfo->name,'\\','/');
 	if (lowercase) {
-		strlower_m(finfo->name);
+		if (!strlower_m(finfo->name)) {
+			return NT_STATUS_INVALID_PARAMETER;
+		}
 	}
 
 	if (!directory_exist(finfo->name) &&
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index c0b6e4e..cae512b 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -173,7 +173,7 @@ static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime
 	fixtarname(hb.dbuf.name, aname, (l+2 >= NAMSIZ) ? NAMSIZ : l + 2);
 
 	if (lowercase)
-		strlower_m(hb.dbuf.name);
+		(void)strlower_m(hb.dbuf.name);
 
 	/* write out a "standard" tar format header */
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index ebb76ef..9af72a1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -662,7 +662,7 @@ ssize_t tstream_read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
 bool strnequal(const char *s1,const char *s2,size_t n);
 bool strcsequal(const char *s1,const char *s2);
-void strnorm(char *s, int case_default);
+bool strnorm(char *s, int case_default);
 char *push_skip_string(char *buf);
 char *skip_string(const char *base, size_t len, char *buf);
 size_t str_charnum(const char *s);
@@ -701,8 +701,8 @@ char *strchr_m(const char *src, char c);
 char *strrchr_m(const char *s, char c);
 char *strnrchr_m(const char *s, char c, unsigned int n);
 char *strstr_m(const char *src, const char *findstr);
-void strlower_m(char *s);
-void strupper_m(char *s);
+bool strlower_m(char *s);
+bool strupper_m(char *s);
 size_t strlen_m(const char *s);
 size_t strlen_m_term(const char *s);
 size_t strlen_m_term_null(const char *s);
diff --git a/source3/lib/afs.c b/source3/lib/afs.c
index 849e9ce..4b6e6ec 100644
--- a/source3/lib/afs.c
+++ b/source3/lib/afs.c
@@ -259,7 +259,9 @@ bool afs_login(connection_struct *conn)
 
 	/* The pts command always generates completely lower-case user
 	 * names. */
-	strlower_m(afs_username);
+	if (!strlower_m(afs_username)) {
+		return false;
+	}
 
 	cell = strchr(afs_username, '@');
 
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 5863d72..32ba97a 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -61,7 +61,10 @@ size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags)
 		if (!tmpbuf) {
 			smb_panic("malloc fail");
 		}
-		strupper_m(tmpbuf);
+		if (!strupper_m(tmpbuf)) {
+			SAFE_FREE(tmpbuf);
+			return (size_t)-1;
+		}
 		src = tmpbuf;
 	}
 
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 4458286..a254bca 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -66,7 +66,10 @@ bool set_local_machine_name(const char *local_name, bool perm)
 	/* alpha_strcpy includes the space for the terminating nul. */
 	alpha_strcpy(local_machine,tmp_local_machine,
 			SAFE_NETBIOS_CHARS,len+1);
-	strlower_m(local_machine);
+	if (!strlower_m(local_machine)) {
+		TALLOC_FREE(tmp_local_machine);
+		return false;
+	}
 	TALLOC_FREE(tmp_local_machine);
 
 	already_perm = perm;
@@ -118,7 +121,10 @@ bool set_remote_machine_name(const char *remote_name, bool perm)
 	/* alpha_strcpy includes the space for the terminating nul. */
 	alpha_strcpy(remote_machine,tmp_remote_machine,
 			SAFE_NETBIOS_CHARS,len+1);
-	strlower_m(remote_machine);
+	if (!strlower_m(remote_machine)) {
+		TALLOC_FREE(tmp_remote_machine);
+		return false;
+	}
 	TALLOC_FREE(tmp_remote_machine);
 
 	already_perm = perm;
@@ -153,7 +159,10 @@ void sub_set_smb_name(const char *name)
 		return;
 	}
 	trim_char(tmp, ' ', ' ');
-	strlower_m(tmp);
+	if (!strlower_m(tmp)) {
+		TALLOC_FREE(tmp);
+		return;
+	}
 
 	len = strlen(tmp);
 
diff --git a/source3/lib/username.c b/source3/lib/username.c
index 5192004..665fbb4 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -112,7 +112,11 @@ static struct passwd *Get_Pwnam_internals(TALLOC_CTX *mem_ctx,
 
 	/* Try in all lower case first as this is the most 
 	   common case on UNIX systems */
-	strlower_m(user2);
+	if (!strlower_m(user2)) {
+		DEBUG(5,("strlower_m %s failed\n", user2));
+		goto done;
+	}
+
 	DEBUG(5,("Trying _Get_Pwnam(), username as lowercase is %s\n",user2));
 	ret = getpwnam_alloc_cached(mem_ctx, user2);
 	if(ret)
@@ -128,7 +132,10 @@ static struct passwd *Get_Pwnam_internals(TALLOC_CTX *mem_ctx,
 	}
 
 	/* Try as uppercase, if username wasn't originally uppercase */
-	strupper_m(user2);
+	if (!strupper_m(user2)) {
+		goto done;
+	}
+
 	if(strcmp(user, user2) != 0) {
 		DEBUG(5,("Trying _Get_Pwnam(), username as uppercase is %s\n",
 			 user2));
@@ -138,7 +145,10 @@ static struct passwd *Get_Pwnam_internals(TALLOC_CTX *mem_ctx,
 	}
 
 	/* Try all combinations up to usernamelevel */
-	strlower_m(user2);
+	if (!strlower_m(user2)) {
+		DEBUG(5,("strlower_m %s failed\n", user2));
+		goto done;
+	}
 	DEBUG(5,("Checking combinations of %d uppercase letters in %s\n",
 		 lp_usernamelevel(), user2));
 	ret = uname_string_combinations(user2, mem_ctx, getpwnam_alloc_cached,
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 9c380c5..b8513f6 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1892,8 +1892,14 @@ bool unix_wild_match(const char *pattern, const char *string)
 		TALLOC_FREE(ctx);
 		return false;
 	}
-	strlower_m(p2);
-	strlower_m(s2);
+	if (!strlower_m(p2)) {
+		TALLOC_FREE(ctx);
+		return false;
+	}
+	if (!strlower_m(s2)) {
+		TALLOC_FREE(ctx);
+		return false;
+	}
 
 	/* Remove any *? and ** from the pattern as they are meaningless */
 	for(p = p2; *p; p++) {
diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c
index 0e128ea..cf54a0e 100644
--- a/source3/lib/util_names.c
+++ b/source3/lib/util_names.c
@@ -63,8 +63,7 @@ static bool set_my_netbios_names(const char *name, int i)
 	smb_my_netbios_names[i] = SMB_STRDUP(name);
 	if (!smb_my_netbios_names[i])
 		return False;
-	strupper_m(smb_my_netbios_names[i]);
-	return True;
+	return strupper_m(smb_my_netbios_names[i]);
 }
 
 /***********************************************************************
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index bfa6652..aa77d75 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -55,12 +55,12 @@ bool strnequal(const char *s1,const char *s2,size_t n)
  Convert a string to "normal" form.
 **/
 
-void strnorm(char *s, int case_default)
+bool strnorm(char *s, int case_default)
 {
 	if (case_default == CASE_UPPER)
-		strupper_m(s);
+		return strupper_m(s);
 	else
-		strlower_m(s);
+		return strlower_m(s);
 }
 
 /**
@@ -414,11 +414,11 @@ static bool unix_strlower(const char *src, size_t srclen, char *dest, size_t des
 	if (!convert_string_talloc(talloc_tos(), CH_UNIX, CH_UTF16LE, src, srclen,
 				   (void **)(void *)&buffer, &size))
 	{
-		smb_panic("failed to create UCS2 buffer");
+		return false;
 	}
 	if (!strlower_w(buffer) && (dest == src)) {
 		TALLOC_FREE(buffer);
-		return srclen;
+		return true;
 	}
 	ret = convert_string(CH_UTF16LE, CH_UNIX, buffer, size, dest, destlen, &size);
 	TALLOC_FREE(buffer);
@@ -460,10 +460,11 @@ _PUBLIC_ void strlower_m(char *s)
  Convert a string to lower case.
 **/
 
-void strlower_m(char *s)
+bool strlower_m(char *s)
 {
 	size_t len;
 	int errno_save;
+	bool ret = false;
 
 	/* this is quite a common operation, so we want it to be
 	   fast. We optimise for the ascii case, knowing that all our
@@ -476,18 +477,20 @@ void strlower_m(char *s)
 	}
 
 	if (!*s)
-		return;
+		return true;
 
 	/* I assume that lowercased string takes the same number of bytes
 	 * as source string even in UTF-8 encoding. (VIV) */
 	len = strlen(s) + 1;
 	errno_save = errno;
 	errno = 0;
-	unix_strlower(s,len,s,len);
+	ret = unix_strlower(s,len,s,len);
 	/* Catch mb conversion errors that may not terminate. */
-	if (errno)
+	if (errno) {
 		s[len-1] = '\0';
+	}
 	errno = errno_save;
+	return ret;
 }
 
 static bool unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
@@ -497,12 +500,12 @@ static bool unix_strupper(const char *src, size_t srclen, char *dest, size_t des
 	bool ret;
 
 	if (!push_ucs2_talloc(talloc_tos(), &buffer, src, &size)) {
-		return (size_t)-1;
+		return false;
 	}
 
 	if (!strupper_w(buffer) && (dest == src)) {
 		TALLOC_FREE(buffer);
-		return srclen;
+		return true;
 	}
 
 	ret = convert_string(CH_UTF16LE, CH_UNIX, buffer, size, dest, destlen, &size);
@@ -545,10 +548,11 @@ _PUBLIC_ void strupper_m(char *s)
  Convert a string to upper case.
 **/
 
-void strupper_m(char *s)
+bool strupper_m(char *s)
 {
 	size_t len;
 	int errno_save;
+	bool ret = false;
 
 	/* this is quite a common operation, so we want it to be
 	   fast. We optimise for the ascii case, knowing that all our
@@ -561,18 +565,20 @@ void strupper_m(char *s)
 	}
 
 	if (!*s)
-		return;
+		return true;
 
 	/* I assume that lowercased string takes the same number of bytes
 	 * as source string even in multibyte encoding. (VIV) */
 	len = strlen(s) + 1;
 	errno_save = errno;
 	errno = 0;
-	unix_strupper(s,len,s,len);
+	ret = unix_strupper(s,len,s,len);
 	/* Catch mb conversion errors that may not terminate. */
-	if (errno)
+	if (errno) {
 		s[len-1] = '\0';
+	}
 	errno = errno_save;
+	return ret;
 }
 
 /**
@@ -983,7 +989,11 @@ int asprintf_strupper_m(char **strp, const char *fmt, ...)
 	if (ret == -1)
 		return -1;
 
-	strupper_m(result);
+	if (!strupper_m(result)) {
+		SAFE_FREE(result);
+		return -1;
+	}
+
 	*strp = result;
 	return ret;
 }
@@ -1000,7 +1010,10 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...)
 	if (ret == NULL) {
 		return NULL;
 	}
-	strupper_m(ret);
+	if (!strupper_m(ret)) {
+		TALLOC_FREE(ret);
+		return NULL;
+	}
 	return ret;
 }
 
@@ -1016,7 +1029,10 @@ char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...)
 	if (ret == NULL) {
 		return NULL;
 	}
-	strlower_m(ret);
+	if (!strlower_m(ret)) {
+		TALLOC_FREE(ret);
+		return NULL;
+	}
 	return ret;
 }
 
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
index 285057b..45d00a3 100644
--- a/source3/libads/ads_struct.c
+++ b/source3/libads/ads_struct.c
@@ -108,7 +108,11 @@ char *ads_build_domain(const char *dn)
 		return NULL;		
 	}	
 
-	strlower_m( dnsdomain );	
+	if (!strlower_m( dnsdomain )) {
+		SAFE_FREE(dnsdomain);
+		return NULL;
+	}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list