summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-11-15 16:09:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:13 -0500
commitc046f2e7a35e2cef2c1482f7d6a3f16be45b49d4 (patch)
tree1df703df31a91e4b2ab398853894ceb1ddae2aeb /source4/lib/ldb/common
parenta39db6303060466ab82366ac9395a6b5a9ca4627 (diff)
downloadsamba-c046f2e7a35e2cef2c1482f7d6a3f16be45b49d4.tar.gz
samba-c046f2e7a35e2cef2c1482f7d6a3f16be45b49d4.tar.bz2
samba-c046f2e7a35e2cef2c1482f7d6a3f16be45b49d4.zip
r19720: - don't pass a pointer reference to ldb_search_default_callback()
as it's ugly when it free's the callers memory on failure! - only steal the controls on a LDB_REPLY_EXTENDED, LDB_REPLY_DONE and ignore them on LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL as we currently have not way to return them in a ldb_result (we should fix this!) metze (This used to be commit 47da62b15abf48f97ce6fc8dc4627792728349ae)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 0eacf214b5..9e0ee6ebca 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -532,12 +532,13 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
return LDB_ERR_OPERATIONS_ERROR;
}
- res = *((struct ldb_result **)context);
+ res = talloc_get_type(context, struct ldb_result);
if (!res || !ares) {
+ ldb_set_errstring(ldb, "NULL res or ares in callback");
goto error;
}
-
+
switch (ares->type) {
case LDB_REPLY_ENTRY:
res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
@@ -566,18 +567,15 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
res->refs[n + 1] = NULL;
case LDB_REPLY_EXTENDED:
case LDB_REPLY_DONE:
- /* Should do something here to detect if this never
- * happens */
+ /* TODO: we should really support controls on entries and referrals too! */
+ res->controls = talloc_move(res, &ares->controls);
break;
}
- talloc_steal(res, ares->controls);
talloc_free(ares);
return LDB_SUCCESS;
error:
talloc_free(ares);
- talloc_free(res);
- *((struct ldb_result **)context) = NULL;
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -753,16 +751,19 @@ int ldb_search(struct ldb_context *ldb,
enum ldb_scope scope,
const char *expression,
const char * const *attrs,
- struct ldb_result **res)
+ struct ldb_result **_res)
{
struct ldb_request *req;
int ret;
+ struct ldb_result *res;
+
+ *_res = NULL;
- *res = talloc_zero(ldb, struct ldb_result);
- if (! *res) {
+ res = talloc_zero(ldb, struct ldb_result);
+ if (!res) {
return LDB_ERR_OPERATIONS_ERROR;
}
-
+
ret = ldb_build_search_req(&req, ldb, ldb,
base?base:ldb_get_default_basedn(ldb),
scope,
@@ -786,10 +787,10 @@ int ldb_search(struct ldb_context *ldb,
done:
if (ret != LDB_SUCCESS) {
- talloc_free(*res);
- *res = NULL;
+ talloc_free(res);
}
+ *_res = res;
return ret;
}