diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-10-06 05:41:32 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:26 -0500 |
commit | 12399c9b5e9b66ab95bd67142d181ccaecb067e2 (patch) | |
tree | 21d0c77d861e80adbb9bf942085df341bd3edc8f /source4 | |
parent | 97e8c5bcecb1fe4ef551906540b3d299f7c9c682 (diff) | |
download | samba-12399c9b5e9b66ab95bd67142d181ccaecb067e2.tar.gz samba-12399c9b5e9b66ab95bd67142d181ccaecb067e2.tar.bz2 samba-12399c9b5e9b66ab95bd67142d181ccaecb067e2.zip |
r10755: fixed the construction of expressions from subtrees for SUBSTRING searches
(This used to be commit 71c06778d4a3ac1ca4198071ae3351acdc0656d9)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/common/ldb_parse.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |