From 12399c9b5e9b66ab95bd67142d181ccaecb067e2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Oct 2005 05:41:32 +0000 Subject: r10755: fixed the construction of expressions from subtrees for SUBSTRING searches (This used to be commit 71c06778d4a3ac1ca4198071ae3351acdc0656d9) --- source4/lib/ldb/common/ldb_parse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index 95110bfd00..110361d2b7 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -686,7 +686,8 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree) talloc_free(s); return ret; case LDB_OP_SUBSTRING: - ret = talloc_strdup(mem_ctx, (tree->u.substring.start_with_wildcard)?"*":""); + ret = talloc_asprintf(mem_ctx, "(%s=%s", tree->u.substring.attr, + tree->u.substring.start_with_wildcard?"*":""); if (ret == NULL) return NULL; for (i = 0; tree->u.substring.chunks[i]; i++) { s2 = ldb_binary_encode(mem_ctx, *(tree->u.substring.chunks[i])); @@ -704,6 +705,12 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree) if ( ! tree->u.substring.end_with_wildcard ) { ret[strlen(ret) - 1] = '\0'; /* remove last wildcard */ } + s = talloc_asprintf_append(ret, ")"); + if (s == NULL) { + talloc_free(ret); + return NULL; + } + ret = s; return ret; case LDB_OP_GREATER: s = ldb_binary_encode(mem_ctx, tree->u.equality.value); -- cgit