From 82da2d401e54d0b3124b727fab755d94dd5402d4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 8 Mar 2006 01:01:14 +0000 Subject: r13998: From now on ldb_request() will require an alloced request By freeing the request you will be sure everything down the path get freed. this also means you have to steal the results if you want to keep them :) simo. (This used to be commit e8075e6a062ce5edb84485e45d0b841c2ee2af7d) --- source4/lib/ldb/tools/ldbsearch.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source4/lib/ldb/tools') diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index fbf32c0777..77f54fee65 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -68,33 +68,34 @@ static int do_search(struct ldb_context *ldb, int loop = 0; int total = 0; int refs = 0; - struct ldb_request req; + struct ldb_request *req; struct ldb_result *result = NULL; - req.operation = LDB_REQ_SEARCH; - req.op.search.base = basedn; - req.op.search.scope = options->scope; - req.op.search.tree = ldb_parse_tree(ldb, expression); - if (req.op.search.tree == NULL) return -1; - req.op.search.attrs = attrs; - req.op.search.res = NULL; - req.controls = parse_controls(ldb, options->controls); - if (options->controls != NULL && req.controls == NULL) return -1; - req.creds = NULL; + req = talloc(ldb, struct ldb_request); + req->operation = LDB_REQ_SEARCH; + req->op.search.base = basedn; + req->op.search.scope = options->scope; + req->op.search.tree = ldb_parse_tree(ldb, expression); + if (req->op.search.tree == NULL) return -1; + req->op.search.attrs = attrs; + req->op.search.res = NULL; + req->controls = parse_controls(ldb, options->controls); + if (options->controls != NULL && req->controls == NULL) return -1; + req->creds = NULL; do { loop = 0; - ret = ldb_request(ldb, &req); + ret = ldb_request(ldb, req); if (ret != LDB_SUCCESS) { printf("search failed - %s\n", ldb_errstring(ldb)); - if (req.op.search.res && req.op.search.res->controls) { - handle_controls_reply(req.op.search.res->controls, req.controls); + if (req->op.search.res && req->op.search.res->controls) { + handle_controls_reply(req->op.search.res->controls, req->controls); } return -1; } - result = req.op.search.res; + result = req->op.search.res; if (options->sorted) { ldb_qsort(result->msgs, result->count, sizeof(struct ldb_message *), @@ -127,7 +128,7 @@ static int do_search(struct ldb_context *ldb, } if (result->controls) { - if (handle_controls_reply(result->controls, req.controls) == 1) + if (handle_controls_reply(result->controls, req->controls) == 1) loop = 1; } @@ -139,7 +140,7 @@ static int do_search(struct ldb_context *ldb, } } - req.op.search.res = NULL; + req->op.search.res = NULL; } while(loop); -- cgit