svn commit: samba r10665 - in
branches/SAMBA_4_0/source/lib/ldb/common: .
tridge at samba.org
tridge at samba.org
Fri Sep 30 23:14:31 GMT 2005
Author: tridge
Date: 2005-09-30 23:14:30 +0000 (Fri, 30 Sep 2005)
New Revision: 10665
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10665
Log:
fixed some crash errors and an error encoding AND and OR operations in the expression parsing code
Modified:
branches/SAMBA_4_0/source/lib/ldb/common/ldb_parse.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_parse.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_parse.c 2005-09-30 23:10:20 UTC (rev 10664)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_parse.c 2005-09-30 23:14:30 UTC (rev 10665)
@@ -354,6 +354,11 @@
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 @@
*/
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 *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 @@
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);
More information about the samba-cvs
mailing list