[SCM] Samba Shared Repository - branch master updated - aa982895e5c13497144740e90ff9646e1d1cf995

Jelmer Vernooij jelmer at samba.org
Mon Oct 13 03:27:02 GMT 2008


The branch, master has been updated
       via  aa982895e5c13497144740e90ff9646e1d1cf995 (commit)
      from  d5a11f9679be9d053838074f1dad5a0ca880750f (commit)

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


- Log -----------------------------------------------------------------
commit aa982895e5c13497144740e90ff9646e1d1cf995
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Mon Oct 13 05:20:26 2008 +0200

    Add data_blob_string_const_null() function that includes the terminating
    null byte and use it in Samba 3.
    
    This matches the behaviour prior to my data_blob changes.

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

Summary of changes:
 lib/util/data_blob.c             |   12 ++++++++++++
 lib/util/data_blob.h             |    8 ++++++++
 source3/auth/token_util.c        |    4 ++--
 source3/lib/access.c             |    6 +++---
 source3/lib/util_pw.c            |    4 ++--
 source3/lib/util_sock.c          |   12 ++++++------
 source3/rpc_server/srv_samr_nt.c |    4 ++--
 source3/torture/torture.c        |    2 +-
 8 files changed, 36 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/data_blob.c b/lib/util/data_blob.c
index 1b2f055..c7d01ba 100644
--- a/lib/util/data_blob.c
+++ b/lib/util/data_blob.c
@@ -183,6 +183,18 @@ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str)
 }
 
 /**
+  useful for constructing data blobs in test suites, while
+  avoiding const warnings
+**/
+_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str)
+{
+	DATA_BLOB blob;
+	blob.data = discard_const_p(uint8_t, str);
+	blob.length = str ? strlen(str)+1 : 0;
+	return blob;
+}
+
+/**
  * Create a new data blob from const data 
  */
 
diff --git a/lib/util/data_blob.h b/lib/util/data_blob.h
index 58c1117..ffde51c 100644
--- a/lib/util/data_blob.h
+++ b/lib/util/data_blob.h
@@ -105,6 +105,14 @@ _PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob);
 _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str);
 
 /**
+  useful for constructing data blobs in test suites, while
+  avoiding const warnings
+
+  includes the terminating null character (as opposed to data_blo_string_const)
+**/
+_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str);
+
+/**
  * Create a new data blob from const data 
  */
 _PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length);
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index d6cd2ea..e739fda 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -84,7 +84,7 @@ NT_USER_TOKEN *get_root_nt_token( void )
 
 	cache_data = memcache_lookup_talloc(
 		NULL, SINGLETON_CACHE_TALLOC,
-		data_blob_string_const("root_nt_token"));
+		data_blob_string_const_null("root_nt_token"));
 
 	if (cache_data != NULL) {
 		return talloc_get_type_abort(
@@ -109,7 +109,7 @@ NT_USER_TOKEN *get_root_nt_token( void )
 
 	memcache_add_talloc(
 		NULL, SINGLETON_CACHE_TALLOC,
-		data_blob_string_const("root_nt_token"), token);
+		data_blob_string_const_null("root_nt_token"), token);
 
 	return token;
 }
diff --git a/source3/lib/access.c b/source3/lib/access.c
index 6a445f8..966d8ce 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -104,7 +104,7 @@ static bool string_match(const char *tok,const char *s)
 
 		if (memcache_lookup(
 			    NULL, SINGLETON_CACHE,
-			    data_blob_string_const("yp_default_domain"),
+			    data_blob_string_const_null("yp_default_domain"),
 			    &tmp)) {
 
 			SMB_ASSERT(tmp.length > 0);
@@ -116,8 +116,8 @@ static bool string_match(const char *tok,const char *s)
 
 			memcache_add(
 				NULL, SINGLETON_CACHE,
-				data_blob_string_const("yp_default_domain"),
-				data_blob_string_const(mydomain?mydomain:""));
+				data_blob_string_const_null("yp_default_domain"),
+				data_blob_string_const_null(mydomain?mydomain:""));
 		}
 
 		if (!mydomain) {
diff --git a/source3/lib/util_pw.c b/source3/lib/util_pw.c
index 4283785..c0d37f1 100644
--- a/source3/lib/util_pw.c
+++ b/source3/lib/util_pw.c
@@ -47,7 +47,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
 	struct passwd *temp, *cached;
 
 	temp = (struct passwd *)memcache_lookup_talloc(
-		NULL, GETPWNAM_CACHE, data_blob_string_const(name));
+		NULL, GETPWNAM_CACHE, data_blob_string_const_null(name));
 	if (temp != NULL) {
 		return tcopy_passwd(mem_ctx, temp);
 	}
@@ -65,7 +65,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
 		return temp;
 	}
 
-	memcache_add_talloc(NULL, GETPWNAM_CACHE, data_blob_string_const(name),
+	memcache_add_talloc(NULL, GETPWNAM_CACHE, data_blob_string_const_null(name),
 			    cached);
 	return tcopy_passwd(mem_ctx, temp);
 }
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index e20768e..f3dc3fc 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1706,7 +1706,7 @@ static bool lookup_nc(struct name_addr_pair *nc)
 
 	if (!memcache_lookup(
 			NULL, SINGLETON_CACHE,
-			data_blob_string_const("get_peer_name"),
+			data_blob_string_const_null("get_peer_name"),
 			&tmp)) {
 		return false;
 	}
@@ -1733,7 +1733,7 @@ static void store_nc(const struct name_addr_pair *nc)
 	memcpy(tmp.data+sizeof(nc->ss), nc->name, namelen+1);
 
 	memcache_add(NULL, SINGLETON_CACHE,
-			data_blob_string_const("get_peer_name"),
+			data_blob_string_const_null("get_peer_name"),
 			tmp);
 	data_blob_free(&tmp);
 }
@@ -1945,7 +1945,7 @@ const char *get_mydnsfullname(void)
 	DATA_BLOB tmp;
 
 	if (memcache_lookup(NULL, SINGLETON_CACHE,
-			data_blob_string_const("get_mydnsfullname"),
+			data_blob_string_const_null("get_mydnsfullname"),
 			&tmp)) {
 		SMB_ASSERT(tmp.length > 0);
 		return (const char *)tmp.data;
@@ -1989,11 +1989,11 @@ const char *get_mydnsfullname(void)
 	 */
 
 	memcache_add(NULL, SINGLETON_CACHE,
-			data_blob_string_const("get_mydnsfullname"),
-			data_blob_string_const(res->ai_canonname));
+			data_blob_string_const_null("get_mydnsfullname"),
+			data_blob_string_const_null(res->ai_canonname));
 
 	if (!memcache_lookup(NULL, SINGLETON_CACHE,
-			data_blob_string_const("get_mydnsfullname"),
+			data_blob_string_const_null("get_mydnsfullname"),
 			&tmp)) {
 		tmp = data_blob_talloc(talloc_tos(), res->ai_canonname,
 				strlen(res->ai_canonname) + 1);
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 6455f02..d4ce349 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2437,7 +2437,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx,
 	if (munged_dial) {
 		blob = base64_decode_data_blob(munged_dial);
 	} else {
-		blob = data_blob_string_const("");
+		blob = data_blob_string_const_null("");
 	}
 
 	status = init_samr_parameters_string(mem_ctx, &blob, &parameters);
@@ -2546,7 +2546,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx,
 	if (munged_dial) {
 		blob = base64_decode_data_blob(munged_dial);
 	} else {
-		blob = data_blob_string_const("");
+		blob = data_blob_string_const_null("");
 	}
 
 	status = init_samr_parameters_string(mem_ctx, &blob, &parameters);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 25b0421..db60a23 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5066,7 +5066,7 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 
-	blob = data_blob_string_const("bar");
+	blob = data_blob_string_const_null("bar");
 	tm = time(NULL);
 
 	if (!gencache_set_data_blob("foo", &blob, tm)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list