summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-30 23:14:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:15 -0500
commitb1ee0c2fa4c4e0a044694a03002dbe320ec8977e (patch)
treec6a21887f660c686c33c8a75576a8611bd98c3a0 /source4/lib
parentecbf28630ef0fbd91838001e03f8c6d29a8d4232 (diff)
downloadsamba-b1ee0c2fa4c4e0a044694a03002dbe320ec8977e.tar.gz
samba-b1ee0c2fa4c4e0a044694a03002dbe320ec8977e.tar.bz2
samba-b1ee0c2fa4c4e0a044694a03002dbe320ec8977e.zip
r10665: fixed some crash errors and an error encoding AND and OR operations in the expression parsing code
(This used to be commit 0d4a900ce5705856d61c6dd4ccb8fdbd049d22b7)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb_parse.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index 83fcc73941..f43d7a7c7a 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -354,6 +354,11 @@ static struct ldb_parse_tree *ldb_parse_simple(void *mem_ctx, const char **s)
switch (filtertype) {
+ case LDB_OP_PRESENT:
+ ret->operation = LDB_OP_PRESENT;
+ ret->u.present.attr = attr;
+ break;
+
case LDB_OP_EQUALITY:
if (strcmp(value, "*") == 0) {
@@ -615,6 +620,11 @@ static struct ldb_parse_tree *ldb_parse_filter(void *mem_ctx, const char **s)
*/
struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s)
{
+ /* allowing NULL makes the _bytree() searches easier */
+ if (s == NULL) {
+ return NULL;
+ }
+
while (isspace((unsigned char)*s)) s++;
if (*s == '(') {
@@ -633,10 +643,14 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree)
char *s, *s2, *ret;
int i;
+ if (tree == NULL) {
+ return NULL;
+ }
+
switch (tree->operation) {
case LDB_OP_AND:
case LDB_OP_OR:
- ret = talloc_asprintf(mem_ctx, "(%c", (char)tree->operation);
+ ret = talloc_asprintf(mem_ctx, "(%c", tree->operation==LDB_OP_AND?'&':'|');
if (ret == NULL) return NULL;
for (i=0;i<tree->u.list.num_elements;i++) {
s = ldb_filter_from_tree(mem_ctx, tree->u.list.elements[i]);
@@ -707,8 +721,7 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree)
talloc_free(s);
return ret;
case LDB_OP_PRESENT:
- ret = talloc_strdup(mem_ctx, "*");
- if (ret == NULL) return NULL;
+ ret = talloc_asprintf(mem_ctx, "(%s=*)", tree->u.present.attr);
return ret;
case LDB_OP_APPROX:
s = ldb_binary_encode(mem_ctx, tree->u.equality.value);