summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-12-01 11:04:19 +0200
committerKamen Mazdrashki <kamenim@samba.org>2010-12-01 11:45:48 +0100
commit4cd16dde148662700311501e62ba3ee9bf80765a (patch)
treec08f68ad2db5e700019af5d834aa23b0c006eea1 /source4
parent6e27ff36b6b112d3b9eb6e4955b717190ab9fb0d (diff)
downloadsamba-4cd16dde148662700311501e62ba3ee9bf80765a.tar.gz
samba-4cd16dde148662700311501e62ba3ee9bf80765a.tar.bz2
samba-4cd16dde148662700311501e62ba3ee9bf80765a.zip
s4-ranged_result.c: Fix memory context for ranged attributes handling
Pair-Programmed-With: Zahari Zahariev <zahari.zahariev@postpath.com> Autobuild-User: Kamen Mazdrashki <kamenim@samba.org> Autobuild-Date: Wed Dec 1 11:45:48 CET 2010 on sn-devel-104
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/ranged_results.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c
index b3e79d0881..f8e8db60b7 100644
--- a/source4/dsdb/samdb/ldb_modules/ranged_results.c
+++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c
@@ -59,6 +59,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
struct ldb_context *ldb;
struct rr_context *ac;
unsigned int i, j;
+ TALLOC_CTX *temp_ctx;
ac = talloc_get_type(req->context, struct rr_context);
ldb = ldb_module_get_ctx(ac->module);
@@ -83,6 +84,13 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
/* LDB_REPLY_ENTRY */
+ temp_ctx = talloc_new(ac->req);
+ if (!temp_ctx) {
+ ldb_module_oom(ac->module);
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
+ }
+
/* Find those that are range requests from the attribute list */
for (i = 0; ac->req->op.search.attrs[i]; i++) {
char *p, *new_attr;
@@ -90,6 +98,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
unsigned int start, end, orig_num_values;
struct ldb_message_element *el;
struct ldb_val *orig_values;
+
p = strchr(ac->req->op.search.attrs[i], ';');
if (!p) {
continue;
@@ -104,7 +113,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
continue;
}
}
- new_attr = talloc_strndup(ac->req,
+ new_attr = talloc_strndup(temp_ctx,
ac->req->op.search.attrs[i],
(size_t)(p - ac->req->op.search.attrs[i]));
@@ -124,7 +133,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
end_str = "*";
end = el->num_values - 1;
} else {
- end_str = talloc_asprintf(el, "%u", end);
+ end_str = talloc_asprintf(temp_ctx, "%u", end);
if (!end_str) {
ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
@@ -148,7 +157,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
el->num_values = 0;
- el->values = talloc_array(el, struct ldb_val, (end - start) + 1);
+ el->values = talloc_array(ares->message->elements, struct ldb_val, (end - start) + 1);
if (!el->values) {
ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
@@ -159,7 +168,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
el->num_values++;
}
}
- el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str);
+ el->name = talloc_asprintf(el->values, "%s;range=%u-%s", el->name, start, end_str);
if (!el->name) {
ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
@@ -167,6 +176,8 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
}
}
+ talloc_free(temp_ctx);
+
return ldb_module_send_entry(ac->req, ares->message, ares->controls);
}