[SCM] Samba Shared Repository - branch v3-3-stable updated - release-3-3-0-121-gb93bb7a

Karolin Seeger kseeger at samba.org
Fri Feb 20 08:14:51 GMT 2009


The branch, v3-3-stable has been updated
       via  b93bb7a251cef874eb2d872718f845f00726a8bc (commit)
       via  b054455edc927a2a031173b2e9bcb2583ea0cffb (commit)
       via  6681d9066f462e5f403498eaa6066a2b7bd7f08c (commit)
       via  9034f373d433b5f15f1c2966a69b4092456af625 (commit)
       via  9f5ab2af11fbef878956e3e6ef6a1c5c511c707e (commit)
       via  7480b88af9bd1ed36abb816c85f69746d444dadc (commit)
       via  924e5aee5e73a7b54061193a274f2ad662c6b230 (commit)
      from  0523f2463423067e36fb975cba891f25a87ee2fe (commit)

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


- Log -----------------------------------------------------------------
commit b93bb7a251cef874eb2d872718f845f00726a8bc
Author: Karolin Seeger <kseeger at samba.org>
Date:   Fri Feb 20 08:58:58 2009 +0100

    WHATSNEW: Update changes since 3.3.0.
    
    Karolin
    (cherry picked from commit ea6f99daeb6bb720ef0b0b1439a96d24e87973f2)

commit b054455edc927a2a031173b2e9bcb2583ea0cffb
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 19 13:36:45 2009 -0800

    Fix printf warnings found on systems where time_t <> long int.
    Jeremy.
    (cherry picked from commit ea256b2d6d35327d63038554bf0a67d986c8e594)

commit 6681d9066f462e5f403498eaa6066a2b7bd7f08c
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 19 13:09:45 2009 -0800

    Fix printf type warning.
    Jeremy.
    (cherry picked from commit aaba9a7b9a39bd899a748c45502fb8103c863eb9)

commit 9034f373d433b5f15f1c2966a69b4092456af625
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 19 20:03:06 2009 +0100

    Fix a O(n^2) algorithm in regdb_fetch_keys()
    (cherry picked from commit d98c43982c56ef788144a3fd67cdd65a9f95f2be)

commit 9f5ab2af11fbef878956e3e6ef6a1c5c511c707e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 19 11:19:10 2009 -0800

    Backport the semantics of when to delete alternate data streams on a file truncate.
    Needed to fully support stream semantics.
    Jeremy.
    (cherry picked from commit 5a68f1e2c1fd16d315b1e303a90eb6475bbe7b15)

commit 7480b88af9bd1ed36abb816c85f69746d444dadc
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 19 14:16:44 2009 +0100

    Fix a buffer handling bug when adding lots of registry keys
    
    This is *ancient*... From 2002, and nobody noticed until someone added lots of
    shares using net conf... :-)
    (cherry picked from commit 36ae846d15027df5e3a02ffabb08183dad9f6517)
    (cherry picked from commit 13f0a2903257677cc107f861e4ed2b58e52a1e21)

commit 924e5aee5e73a7b54061193a274f2ad662c6b230
Author: Günther Deschner <gd at samba.org>
Date:   Thu Feb 19 02:35:20 2009 +0100

    s3-libnet: fix coverity #848 (UNINIT).
    
    Guenther
    (cherry picked from commit e9d5405948e35a8eec0b49cc6c066278cb523397)
    (cherry picked from commit 3d13df93f0ffaa518a576191a0715add878a7635)

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

Summary of changes:
 WHATSNEW.txt                          |    6 +++
 source/include/proto.h                |    1 +
 source/libnet/libnet_samsync_keytab.c |    2 +-
 source/passdb/pdb_ldap.c              |   16 ++++----
 source/registry/reg_backend_db.c      |   65 ++++++++++++++++++++++++++-------
 source/smbd/close.c                   |    2 +-
 source/smbd/open.c                    |   14 +++++++
 source/utils/smbget.c                 |    3 +-
 8 files changed, 84 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index cdce940..74e8767 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -42,6 +42,9 @@ o   Jeremy Allison <jra at samba.org>
     * Correctly use chroot().
     * Parameterize in local.h the MAX_RPC_DATA_SIZE, and ensure that "offered"
       read from the rpc packet in spoolss is under that size.
+    * Backport the semantics of when to delete alternate data streams on a file
+      truncate.
+    * Fix printf warnings.
 
 
 o   Michael Adam <obnox at samba.org>
@@ -55,6 +58,7 @@ o   Michael Adam <obnox at samba.org>
 
 
 o   Guenther Deschner <gd at samba.org>
+    * Fix Coverity ID 848.
     * Remove unused ENUM_HND from 'net'.
     * Fix getform command asprintf return code in rpcclient.
     * Fix memleak in get_remote_printer_publishing_data().
@@ -85,6 +89,8 @@ o   Volker Lendecke <vl at samba.org>
     * Avoid valgrind errors.
     * Fix 'net rpc join' for users with the SeMachineAccountPrivilege.
     * Fix resume handle for _samr_EnumDomainGroups.
+    * Fix a buffer handling bug when adding lots of registry keys.
+    * Fix a O(n^2) algorithm in regdb_fetch_keys().
 
 
 o   Jeff Layton <jlayton at redhat.com>
diff --git a/source/include/proto.h b/source/include/proto.h
index 716f177..edb0009 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -8690,6 +8690,7 @@ void msg_close_file(struct messaging_context *msg_ctx,
 		    uint32_t msg_type,
 		    struct server_id server_id,
 		    DATA_BLOB *data);
+NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
 
 /* The following definitions come from smbd/conn.c  */
 
diff --git a/source/libnet/libnet_samsync_keytab.c b/source/libnet/libnet_samsync_keytab.c
index cdb3446..7684063 100644
--- a/source/libnet/libnet_samsync_keytab.c
+++ b/source/libnet/libnet_samsync_keytab.c
@@ -111,7 +111,7 @@ static NTSTATUS init_keytab(TALLOC_CTX *mem_ctx,
 {
 	krb5_error_code ret = 0;
 	NTSTATUS status;
-	struct libnet_keytab_context *keytab_ctx;
+	struct libnet_keytab_context *keytab_ctx = NULL;
 	struct libnet_keytab_entry *entry;
 	uint64_t old_sequence_num = 0;
 	const char *principal = NULL;
diff --git a/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c
index 043b620..70a1c62 100644
--- a/source/passdb/pdb_ldap.c
+++ b/source/passdb/pdb_ldap.c
@@ -1249,7 +1249,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 			get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_PROFILE_PATH), 
 			pdb_get_profile_path(sampass));
 
-	if (asprintf(&temp, "%li", pdb_get_logon_time(sampass)) < 0) {
+	if (asprintf(&temp, "%li", (long int)pdb_get_logon_time(sampass)) < 0) {
 		return false;
 	}
 	if (need_update(sampass, PDB_LOGONTIME))
@@ -1257,7 +1257,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 			get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGON_TIME), temp);
 	SAFE_FREE(temp);
 
-	if (asprintf(&temp, "%li", pdb_get_logoff_time(sampass)) < 0) {
+	if (asprintf(&temp, "%li", (long int)pdb_get_logoff_time(sampass)) < 0) {
 		return false;
 	}
 	if (need_update(sampass, PDB_LOGOFFTIME))
@@ -1265,7 +1265,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 			get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGOFF_TIME), temp);
 	SAFE_FREE(temp);
 
-	if (asprintf(&temp, "%li", pdb_get_kickoff_time(sampass)) < 0) {
+	if (asprintf(&temp, "%li", (long int)pdb_get_kickoff_time(sampass)) < 0) {
 		return false;
 	}
 	if (need_update(sampass, PDB_KICKOFFTIME))
@@ -1273,7 +1273,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 			get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_KICKOFF_TIME), temp);
 	SAFE_FREE(temp);
 
-	if (asprintf(&temp, "%li", pdb_get_pass_can_change_time_noncalc(sampass)) < 0) {
+	if (asprintf(&temp, "%li", (long int)pdb_get_pass_can_change_time_noncalc(sampass)) < 0) {
 		return false;
 	}
 	if (need_update(sampass, PDB_CANCHANGETIME))
@@ -1281,7 +1281,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 			get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_PWD_CAN_CHANGE), temp);
 	SAFE_FREE(temp);
 
-	if (asprintf(&temp, "%li", pdb_get_pass_must_change_time(sampass)) < 0) {
+	if (asprintf(&temp, "%li", (long int)pdb_get_pass_must_change_time(sampass)) < 0) {
 		return false;
 	}
 	if (need_update(sampass, PDB_MUSTCHANGETIME))
@@ -1361,7 +1361,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 
 		if (need_update(sampass, PDB_PASSLASTSET)) {
 			if (asprintf(&temp, "%li",
-				pdb_get_pass_last_set_time(sampass)) < 0) {
+				(long int)pdb_get_pass_last_set_time(sampass)) < 0) {
 				return false;
 			}
 			smbldap_make_mod(ldap_state->smbldap_state->ldap_struct, existing, mods,
@@ -1423,7 +1423,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
 				temp);
 			SAFE_FREE(temp);
 
-			if (asprintf(&temp, "%li", badtime) < 0) {
+			if (asprintf(&temp, "%li", (long int)badtime) < 0) {
 				return false;
 			}
 			smbldap_make_mod(
@@ -5941,7 +5941,7 @@ static bool ldapsam_set_trusteddom_pw(struct pdb_methods *methods,
 	smbldap_make_mod(priv2ld(ldap_state), entry, &mods, "sambaSID",
 			 sid_string_tos(sid));
 	smbldap_make_mod(priv2ld(ldap_state), entry, &mods, "sambaPwdLastSet",
-			 talloc_asprintf(talloc_tos(), "%li", time(NULL)));
+			 talloc_asprintf(talloc_tos(), "%li", (long int)time(NULL)));
 	smbldap_make_mod(priv2ld(ldap_state), entry, &mods,
 			 "sambaClearTextPassword", pwd);
 
diff --git a/source/registry/reg_backend_db.c b/source/registry/reg_backend_db.c
index 6f4c614..8ef83a1 100644
--- a/source/registry/reg_backend_db.c
+++ b/source/registry/reg_backend_db.c
@@ -536,21 +536,36 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr)
 	/* pack all the strings */
 
 	for (i=0; i<num_subkeys; i++) {
-		len += tdb_pack(buffer+len, buflen-len, "f",
-				regsubkey_ctr_specific_key(ctr, i));
-		if (len > buflen) {
-			/* allocate some extra space */
-			buffer = (uint8 *)SMB_REALLOC(buffer, len*2);
+		size_t thistime;
+
+		thistime = tdb_pack(buffer+len, buflen-len, "f",
+				    regsubkey_ctr_specific_key(ctr, i));
+		if (len+thistime > buflen) {
+			size_t thistime2;
+			/*
+			 * tdb_pack hasn't done anything because of the short
+			 * buffer, allocate extra space.
+			 */
+			buffer = SMB_REALLOC_ARRAY(buffer, uint8_t,
+						   (len+thistime)*2);
 			if(buffer == NULL) {
 				DEBUG(0, ("regdb_store_keys: Failed to realloc "
-					  "memory of size [%d]\n", len*2));
+					  "memory of size [%u]\n",
+					  (unsigned int)(len+thistime)*2));
+				ret = false;
+				goto done;
+			}
+			buflen = (len+thistime)*2;
+			thistime2 = tdb_pack(
+				buffer+len, buflen-len, "f",
+				regsubkey_ctr_specific_key(ctr, i));
+			if (thistime2 != thistime) {
+				DEBUG(0, ("tdb_pack failed\n"));
 				ret = false;
 				goto done;
 			}
-			buflen = len*2;
-			len = tdb_pack(buffer+len, buflen-len, "f",
-				       regsubkey_ctr_specific_key(ctr, i));
 		}
+		len += thistime;
 	}
 
 	/* finally write out the data */
@@ -927,7 +942,6 @@ done:
 
 int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 {
-	WERROR werr;
 	uint32 num_items;
 	uint8 *buf;
 	uint32 buflen, len;
@@ -958,12 +972,35 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
 	buflen = value.dsize;
 	len = tdb_unpack( buf, buflen, "d", &num_items);
 
+	/*
+	 * The following code breaks the abstraction that reg_objects.c sets
+	 * up with regsubkey_ctr_addkey(). But if we use that with the current
+	 * data structure of ctr->subkeys being an unsorted array, we end up
+	 * with an O(n^2) algorithm for retrieving keys from the tdb
+	 * file. This is pretty pointless, as we have to trust the data
+	 * structure on disk not to have duplicates anyway. The alternative to
+	 * breaking this abstraction would be to set up a more sophisticated
+	 * data structure in REGSUBKEY_CTR.
+	 *
+	 * This makes "net conf list" for a registry with >1000 shares
+	 * actually usable :-)
+	 */
+
+	ctr->subkeys = talloc_array(ctr, char *, num_items);
+	if (ctr->subkeys == NULL) {
+		DEBUG(5, ("regdb_fetch_keys: could not allocate subkeys\n"));
+		goto done;
+	}
+	ctr->num_subkeys = num_items;
+
 	for (i=0; i<num_items; i++) {
 		len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
-		werr = regsubkey_ctr_addkey(ctr, subkeyname);
-		if (!W_ERROR_IS_OK(werr)) {
-			DEBUG(5, ("regdb_fetch_keys: regsubkey_ctr_addkey "
-				  "failed: %s\n", dos_errstr(werr)));
+		ctr->subkeys[i] = talloc_strdup(ctr->subkeys, subkeyname);
+		if (ctr->subkeys[i] == NULL) {
+			DEBUG(5, ("regdb_fetch_keys: could not allocate "
+				  "subkeyname\n"));
+			TALLOC_FREE(ctr->subkeys);
+			ctr->num_subkeys = 0;
 			goto done;
 		}
 	}
diff --git a/source/smbd/close.c b/source/smbd/close.c
index 25552e3..d586116 100644
--- a/source/smbd/close.c
+++ b/source/smbd/close.c
@@ -167,7 +167,7 @@ static void notify_deferred_opens(struct share_mode_lock *lck)
  Delete all streams
 ****************************************************************************/
 
-static NTSTATUS delete_all_streams(connection_struct *conn, const char *fname)
+NTSTATUS delete_all_streams(connection_struct *conn, const char *fname)
 {
 	struct stream_struct *stream_info;
 	int i;
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 716b9ff..bbf1b40 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -1358,6 +1358,7 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn,
 	bool def_acl = False;
 	bool posix_open = False;
 	bool new_file_created = False;
+	bool clear_ads = false;
 	struct file_id id;
 	NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED;
 	mode_t new_unx_mode = (mode_t)0;
@@ -1490,12 +1491,14 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn,
 			/* If file exists replace/overwrite. If file doesn't
 			 * exist create. */
 			flags2 |= (O_CREAT | O_TRUNC);
+			clear_ads = true;
 			break;
 
 		case FILE_OVERWRITE_IF:
 			/* If file exists replace/overwrite. If file doesn't
 			 * exist create. */
 			flags2 |= (O_CREAT | O_TRUNC);
+			clear_ads = true;
 			break;
 
 		case FILE_OPEN:
@@ -1520,6 +1523,7 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn,
 				return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 			}
 			flags2 |= O_TRUNC;
+			clear_ads = true;
 			break;
 
 		case FILE_CREATE:
@@ -1953,6 +1957,16 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn,
 
 	SMB_ASSERT(lck != NULL);
 
+	/* Delete streams if create_disposition requires it */
+	if (file_existed && clear_ads && !is_ntfs_stream_name(fname)) {
+		status = delete_all_streams(conn, fname);
+		if (!NT_STATUS_IS_OK(status)) {
+			TALLOC_FREE(lck);
+			fd_close(fsp);
+			return status;
+		}
+	}
+
 	/* note that we ignore failure for the following. It is
            basically a hack for NFS, and NFS will never set one of
            these only read them. Nobody but Samba can ever set a deny
diff --git a/source/utils/smbget.c b/source/utils/smbget.c
index c062134..7c01f5d 100644
--- a/source/utils/smbget.c
+++ b/source/utils/smbget.c
@@ -487,7 +487,8 @@ static void clean_exit(void)
 {
 	char bs[100];
 	human_readable(total_bytes, bs, sizeof(bs));
-	if(!quiet)fprintf(stderr, "Downloaded %s in %lu seconds\n", bs, time(NULL) - total_start_time);
+	if(!quiet)fprintf(stderr, "Downloaded %s in %lu seconds\n", bs,
+		(unsigned long)(time(NULL) - total_start_time));
 	exit(0);
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list