summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/gencache.c13
-rw-r--r--source3/libsmb/dsgetdcname.c3
-rw-r--r--source3/torture/torture.c4
-rw-r--r--source3/utils/net_cache.c2
5 files changed, 16 insertions, 9 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 078d0398d5..5985d23b65 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -112,7 +112,8 @@ bool gencache_parse(const char *keystr,
void (*parser)(time_t timeout, DATA_BLOB blob,
void *private_data),
void *private_data);
-bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
+bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob,
time_t *timeout, bool *was_expired);
bool gencache_stabilize(void);
bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 08adf2173a..7d89c7d05a 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -368,7 +368,8 @@ bool gencache_del(const char *keystr)
* element.
*/
- exists = gencache_get_data_blob(keystr, &value, NULL, &was_expired);
+ exists = gencache_get_data_blob(keystr, NULL, &value, NULL,
+ &was_expired);
if (!exists && was_expired) {
/*
@@ -469,6 +470,7 @@ bool gencache_parse(const char *keystr,
}
struct gencache_get_data_blob_state {
+ TALLOC_CTX *mem_ctx;
DATA_BLOB *blob;
time_t timeout;
bool result;
@@ -491,7 +493,8 @@ static void gencache_get_data_blob_parser(time_t timeout, DATA_BLOB blob,
return;
}
- *state->blob = data_blob(blob.data, blob.length);
+ *state->blob = data_blob_talloc(state->mem_ctx, blob.data,
+ blob.length);
if (state->blob->data == NULL) {
state->result = false;
return;
@@ -511,13 +514,15 @@ static void gencache_get_data_blob_parser(time_t timeout, DATA_BLOB blob,
* @retval False for failure
**/
-bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
+bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob,
time_t *timeout, bool *was_expired)
{
struct gencache_get_data_blob_state state;
bool expired = false;
state.result = false;
+ state.mem_ctx = mem_ctx;
state.blob = blob;
if (!gencache_parse(keystr, gencache_get_data_blob_parser, &state)) {
@@ -705,7 +710,7 @@ bool gencache_get(const char *keystr, char **value, time_t *ptimeout)
DATA_BLOB blob;
bool ret = False;
- ret = gencache_get_data_blob(keystr, &blob, ptimeout, NULL);
+ ret = gencache_get_data_blob(keystr, NULL, &blob, ptimeout, NULL);
if (!ret) {
return false;
}
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 6818b01d11..4f2aa632fe 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -334,12 +334,13 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- if (!gencache_get_data_blob(key, &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob(key, NULL, &blob, NULL, NULL)) {
return NT_STATUS_NOT_FOUND;
}
info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
if (!info) {
+ data_blob_free(&blob);
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 2d7e87f3e9..15bb8f3d7f 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8172,7 +8172,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (!gencache_get_data_blob("foo", &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
return False;
}
@@ -8196,7 +8196,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (gencache_get_data_blob("foo", &blob, NULL, NULL)) {
+ if (gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() on deleted entry "
"succeeded\n", __location__);
return False;
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index afcb7a1874..4de3a6ce77 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -242,7 +242,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv)
return -1;
}
- if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) {
+ if (gencache_get_data_blob(keystr, NULL, &value, &timeout, NULL)) {
print_cache_entry(keystr, value, timeout, NULL);
data_blob_free(&value);
return 0;