From aa982895e5c13497144740e90ff9646e1d1cf995 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Oct 2008 05:20:26 +0200 Subject: 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. --- source3/lib/access.c | 6 +++--- source3/lib/util_pw.c | 4 ++-- source3/lib/util_sock.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/access.c b/source3/lib/access.c index 6a445f8139..966d8ce87c 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 428378505f..c0d37f1094 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 e20768ed89..f3dc3fc1d1 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); -- cgit