r10756: another fix for the construction of expressions from subtrees for
authorAndrew Tridgell <tridge@samba.org>
Thu, 6 Oct 2005 05:53:46 +0000 (05:53 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:39:27 +0000 (13:39 -0500)
SUBSTRING searches. This time fix multi-part substring searches.
(This used to be commit bf5cef6f00466fc1dc3c2864a109f1ccd92681b0)

source4/lib/ldb/common/ldb_parse.c

index 110361d2b712c64f9e1b6aa75fc0e6619383266c..27f9e1ec255ba0a0f823336c8ba60c475256e7fc 100644 (file)
@@ -695,16 +695,18 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree)
                                talloc_free(ret);
                                return NULL;
                        }
-                       s = talloc_asprintf_append(ret, "%s*", s2);
+                       if (tree->u.substring.chunks[i+1] ||
+                           tree->u.substring.end_with_wildcard) {
+                               s = talloc_asprintf_append(ret, "%s*", s2);
+                       } else {
+                               s = talloc_asprintf_append(ret, "%s", s2);
+                       }
                        if (s == NULL) {
                                talloc_free(ret);
                                return NULL;
                        }
                        ret = s;
                }
-               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);