summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-09-12 21:11:57 +0200
committerVolker Lendecke <vl@samba.org>2011-09-13 11:00:14 +0200
commitad85bd8003fdbefb5f9186408721c766b5e813eb (patch)
tree2d07f362ad0d8f3921fd3c858f9185f51b7961be /source3
parent0e5a876aa7820bdd5b32f84ff7a6a7d254df8073 (diff)
downloadsamba-ad85bd8003fdbefb5f9186408721c766b5e813eb.tar.gz
samba-ad85bd8003fdbefb5f9186408721c766b5e813eb.tar.bz2
samba-ad85bd8003fdbefb5f9186408721c766b5e813eb.zip
s3: Make saf_join_key() use talloc
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/namequery.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 281236ae87..c70e68b103 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -48,13 +48,9 @@ static char *saf_key(TALLOC_CTX *mem_ctx, const char *domain)
return talloc_asprintf_strupper_m(mem_ctx, SAFKEY_FMT, domain);
}
-static char *saf_join_key(const char *domain)
+static char *saf_join_key(TALLOC_CTX *mem_ctx, const char *domain)
{
- char *keystr;
-
- asprintf_strupper_m(&keystr, SAFJOINKEY_FMT, domain);
-
- return keystr;
+ return talloc_asprintf_strupper_m(mem_ctx, SAFJOINKEY_FMT, domain);
}
/****************************************************************************
@@ -111,7 +107,11 @@ bool saf_join_store( const char *domain, const char *servername )
return False;
}
- key = saf_join_key( domain );
+ key = saf_join_key(talloc_tos(), domain);
+ if (key == NULL) {
+ DEBUG(1, ("saf_join_key() failed\n"));
+ return false;
+ }
expire = time( NULL ) + lp_parm_int(-1, "saf","join ttl", SAFJOIN_TTL);
DEBUG(10,("saf_join_store: domain = [%s], server = [%s], expire = [%u]\n",
@@ -119,7 +119,7 @@ bool saf_join_store( const char *domain, const char *servername )
ret = gencache_set( key, servername, expire );
- SAFE_FREE( key );
+ TALLOC_FREE( key );
return ret;
}
@@ -134,9 +134,13 @@ bool saf_delete( const char *domain )
return False;
}
- key = saf_join_key(domain);
+ key = saf_join_key(talloc_tos(), domain);
+ if (key == NULL) {
+ DEBUG(1, ("saf_join_key() failed\n"));
+ return false;
+ }
ret = gencache_del(key);
- SAFE_FREE(key);
+ TALLOC_FREE(key);
if (ret) {
DEBUG(10,("saf_delete[join]: domain = [%s]\n", domain ));
@@ -172,11 +176,15 @@ char *saf_fetch( const char *domain )
return NULL;
}
- key = saf_join_key( domain );
+ key = saf_join_key(talloc_tos(), domain);
+ if (key == NULL) {
+ DEBUG(1, ("saf_join_key() failed\n"));
+ return NULL;
+ }
ret = gencache_get( key, &server, &timeout );
- SAFE_FREE( key );
+ TALLOC_FREE( key );
if ( ret ) {
DEBUG(5,("saf_fetch[join]: Returning \"%s\" for \"%s\" domain\n",