summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-09-04 08:57:59 +0200
committerJeremy Allison <jra@samba.org>2013-09-05 20:09:21 +0200
commitd3c689fc5c80431b7e72150f72465b3d255a6f02 (patch)
tree5345e29db38968ef5692e1c8d2435b2d6a3fe45a /source3
parent32037e0533f720ebbd3f49c5951c4ef30aac9985 (diff)
downloadsamba-d3c689fc5c80431b7e72150f72465b3d255a6f02.tar.gz
samba-d3c689fc5c80431b7e72150f72465b3d255a6f02.tar.bz2
samba-d3c689fc5c80431b7e72150f72465b3d255a6f02.zip
lib: Use "mem_ctx" arg in gencache_get
Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Sep 5 20:09:21 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/user_util.c5
-rw-r--r--source3/lib/gencache.c24
-rw-r--r--source3/lib/idmap_cache.c14
-rw-r--r--source3/libsmb/conncache.c4
-rw-r--r--source3/libsmb/namecache.c8
-rw-r--r--source3/libsmb/trustdom_cache.c10
-rw-r--r--source3/passdb/account_pol.c4
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c6
-rw-r--r--source3/torture/torture.c14
-rw-r--r--source3/winbindd/winbindd_cm.c3
10 files changed, 48 insertions, 44 deletions
diff --git a/source3/auth/user_util.c b/source3/auth/user_util.c
index b52f1dd5bc..70ab5ade65 100644
--- a/source3/auth/user_util.c
+++ b/source3/auth/user_util.c
@@ -96,14 +96,13 @@ static bool fetch_map_from_gencache(TALLOC_CTX *ctx,
if (key == NULL) {
return false;
}
- found = gencache_get(key, NULL, &value, NULL);
+ found = gencache_get(key, ctx, &value, NULL);
TALLOC_FREE(key);
if (!found) {
return false;
}
TALLOC_FREE(*p_user_out);
- *p_user_out = talloc_strdup(ctx, value);
- SAFE_FREE(value);
+ *p_user_out = value;
if (!*p_user_out) {
return false;
}
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 1ecaad5be5..2c5e9ab424 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -711,7 +711,7 @@ bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
DATA_BLOB blob;
bool ret = False;
- ret = gencache_get_data_blob(keystr, NULL, &blob, ptimeout, NULL);
+ ret = gencache_get_data_blob(keystr, mem_ctx, &blob, ptimeout, NULL);
if (!ret) {
return false;
}
@@ -725,11 +725,7 @@ bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
return false;
}
if (value) {
- *value = SMB_STRDUP((char *)blob.data);
- data_blob_free(&blob);
- if (*value == NULL) {
- return false;
- }
+ *value = talloc_move(mem_ctx, (char **)&blob.data);
return true;
}
data_blob_free(&blob);
@@ -783,8 +779,11 @@ static int gencache_iterate_blobs_fn(struct tdb_context *tdb, TDB_DATA key,
keystr = (char *)key.dptr;
} else {
/* ensure 0-termination */
- keystr = SMB_STRNDUP((char *)key.dptr, key.dsize);
+ keystr = talloc_strndup(talloc_tos(), (char *)key.dptr, key.dsize);
free_key = keystr;
+ if (keystr == NULL) {
+ goto done;
+ }
}
if (!gencache_pull_timeout((char *)data.dptr, &timeout, &endptr)) {
@@ -806,7 +805,7 @@ static int gencache_iterate_blobs_fn(struct tdb_context *tdb, TDB_DATA key,
timeout, state->private_data);
done:
- SAFE_FREE(free_key);
+ TALLOC_FREE(free_key);
return 0;
}
@@ -862,8 +861,11 @@ static void gencache_iterate_fn(const char *key, DATA_BLOB value,
valstr = (char *)value.data;
} else {
/* ensure 0-termination */
- valstr = SMB_STRNDUP((char *)value.data, value.length);
+ valstr = talloc_strndup(talloc_tos(), (char *)value.data, value.length);
free_val = valstr;
+ if (valstr == NULL) {
+ goto done;
+ }
}
DEBUG(10, ("Calling function with arguments "
@@ -872,7 +874,9 @@ static void gencache_iterate_fn(const char *key, DATA_BLOB value,
state->fn(key, valstr, timeout, state->private_data);
- SAFE_FREE(free_val);
+ done:
+
+ TALLOC_FREE(free_val);
}
void gencache_iterate(void (*fn)(const char *key, const char *value,
diff --git a/source3/lib/idmap_cache.c b/source3/lib/idmap_cache.c
index 627ced30b3..ffd3c1955c 100644
--- a/source3/lib/idmap_cache.c
+++ b/source3/lib/idmap_cache.c
@@ -48,7 +48,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
if (!ret) {
goto done;
}
@@ -128,7 +128,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
done:
TALLOC_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return ret;
}
@@ -209,7 +209,7 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired)
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
TALLOC_FREE(key);
if (!ret) {
return false;
@@ -218,7 +218,7 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired)
if (value[0] != '-') {
ret = string_to_sid(sid, value);
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
if (ret) {
*expired = (timeout <= time(NULL));
}
@@ -246,7 +246,7 @@ bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired)
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
TALLOC_FREE(key);
if (!ret) {
return false;
@@ -255,7 +255,7 @@ bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired)
if (value[0] != '-') {
ret = string_to_sid(sid, value);
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
if (ret) {
*expired = (timeout <= time(NULL));
}
@@ -431,7 +431,7 @@ static bool idmap_cache_del_xid(char t, int xid)
time_t timeout;
bool ret = true;
- if (!gencache_get(key, NULL, &sid_str, &timeout)) {
+ if (!gencache_get(key, mem_ctx, &sid_str, &timeout)) {
DEBUG(3, ("no entry: %s\n", key));
ret = false;
goto done;
diff --git a/source3/libsmb/conncache.c b/source3/libsmb/conncache.c
index dfc2f471ac..9bf4c56a33 100644
--- a/source3/libsmb/conncache.c
+++ b/source3/libsmb/conncache.c
@@ -143,13 +143,13 @@ NTSTATUS check_negative_conn_cache( const char *domain, const char *server)
if (key == NULL)
goto done;
- if (gencache_get(key, NULL, &value, NULL))
+ if (gencache_get(key, talloc_tos(), &value, NULL))
result = negative_conn_cache_valuedecode(value);
done:
DEBUG(9,("check_negative_conn_cache returning result %d for domain %s "
"server %s\n", NT_STATUS_V(result), domain, server));
TALLOC_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return result;
}
diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c
index ebd51fd919..1e6158444d 100644
--- a/source3/libsmb/namecache.c
+++ b/source3/libsmb/namecache.c
@@ -156,7 +156,7 @@ bool namecache_fetch(const char *name,
return False;
}
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
SAFE_FREE(key);
return False;
@@ -170,7 +170,7 @@ bool namecache_fetch(const char *name,
*num_names = ipstr_list_parse(value, ip_list);
SAFE_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return *num_names > 0; /* true only if some ip has been fetched */
}
@@ -294,7 +294,7 @@ bool namecache_status_fetch(const char *keyname,
if (!key)
return False;
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
key));
SAFE_FREE(key);
@@ -306,6 +306,6 @@ bool namecache_status_fetch(const char *keyname,
strlcpy(srvname_out, value, 16);
SAFE_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return True;
}
diff --git a/source3/libsmb/trustdom_cache.c b/source3/libsmb/trustdom_cache.c
index 81b366a4cc..81d8bf9c7a 100644
--- a/source3/libsmb/trustdom_cache.c
+++ b/source3/libsmb/trustdom_cache.c
@@ -160,7 +160,7 @@ bool trustdom_cache_fetch(const char* name, struct dom_sid* sid)
if (!key)
return False;
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no entry for trusted domain %s found.\n", name));
SAFE_FREE(key);
return False;
@@ -172,11 +172,11 @@ bool trustdom_cache_fetch(const char* name, struct dom_sid* sid)
/* convert sid string representation into struct dom_sid structure */
if(! string_to_sid(sid, value)) {
sid = NULL;
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return False;
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return True;
}
@@ -191,7 +191,7 @@ uint32 trustdom_cache_fetch_timestamp( void )
time_t timeout;
uint32 timestamp;
- if (!gencache_get(TDOMTSKEY, NULL, &value, &timeout)) {
+ if (!gencache_get(TDOMTSKEY, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
SAFE_FREE(value);
return 0;
@@ -199,7 +199,7 @@ uint32 trustdom_cache_fetch_timestamp( void )
timestamp = atoi(value);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return timestamp;
}
diff --git a/source3/passdb/account_pol.c b/source3/passdb/account_pol.c
index 14ff946b51..06925e8af6 100644
--- a/source3/passdb/account_pol.c
+++ b/source3/passdb/account_pol.c
@@ -446,7 +446,7 @@ bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value)
goto done;
}
- if (gencache_get(cache_key, NULL, &cache_value, NULL)) {
+ if (gencache_get(cache_key, talloc_tos(), &cache_value, NULL)) {
uint32 tmp = strtoul(cache_value, NULL, 10);
*value = tmp;
ret = True;
@@ -454,7 +454,7 @@ bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value)
done:
SAFE_FREE(cache_key);
- SAFE_FREE(cache_value);
+ TALLOC_FREE(cache_value);
return ret;
}
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 37f11c78ee..89938e4b9f 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -631,16 +631,16 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s",
aprinter);
if ((cache_key != NULL) &&
- gencache_get(cache_key, NULL, &tmp, NULL)) {
+ gencache_get(cache_key, talloc_tos(), &tmp, NULL)) {
found = (strcmp(tmp, printer_not_found) != 0);
if (!found) {
DEBUG(4, ("Printer %s not found\n", aprinter));
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
return WERR_INVALID_PRINTER_NAME;
}
fstrcpy(sname, tmp);
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
}
/* Search all sharenames first as this is easier than pulling
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index f2446d1e34..8313cf141b 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8135,7 +8135,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (!gencache_get("foo", NULL, &val, &tm)) {
+ if (!gencache_get("foo", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get() failed\n", __location__);
return False;
}
@@ -8143,11 +8143,11 @@ static bool run_local_gencache(int dummy)
if (strcmp(val, "bar") != 0) {
d_printf("%s: gencache_get() returned %s, expected %s\n",
__location__, val, "bar");
- SAFE_FREE(val);
+ TALLOC_FREE(val);
return False;
}
- SAFE_FREE(val);
+ TALLOC_FREE(val);
if (!gencache_del("foo")) {
d_printf("%s: gencache_del() failed\n", __location__);
@@ -8159,7 +8159,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (gencache_get("foo", NULL, &val, &tm)) {
+ if (gencache_get("foo", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get() on deleted entry "
"succeeded\n", __location__);
return False;
@@ -8173,7 +8173,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (!gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
return False;
}
@@ -8197,7 +8197,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
+ if (gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() on deleted entry "
"succeeded\n", __location__);
return False;
@@ -8212,7 +8212,7 @@ static bool run_local_gencache(int dummy)
__location__);
return false;
}
- if (gencache_get("blob", NULL, &val, &tm)) {
+ if (gencache_get("blob", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get succeeded\n", __location__);
return false;
}
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 17ede8c5cf..3906d3d1ff 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -1512,7 +1512,7 @@ bool fetch_current_dc_from_gencache(TALLOC_CTX *mem_ctx,
if (key == NULL) {
goto done;
}
- if (!gencache_get(key, NULL, &value, NULL)) {
+ if (!gencache_get(key, mem_ctx, &value, NULL)) {
goto done;
}
p = strchr(value, ' ');
@@ -1541,6 +1541,7 @@ done:
TALLOC_FREE(dc_name);
TALLOC_FREE(dc_ip);
TALLOC_FREE(key);
+ TALLOC_FREE(value);
return ret;
}