]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Use correct member of union
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 14 Feb 2023 01:18:45 +0000 (14:18 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 5 Apr 2023 02:10:35 +0000 (02:10 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_parse.c
lib/ldb/ldb_map/ldb_map_outbound.c

index 2d102ff750e4a06e42d5154c9784a98c80544e07..f1d224a255e4ec9ff3febf921fb2a9c68b40ce12 100644 (file)
@@ -799,27 +799,27 @@ char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tre
                ret = s;
                return ret;
        case LDB_OP_GREATER:
-               s = ldb_binary_encode(mem_ctx, tree->u.equality.value);
+               s = ldb_binary_encode(mem_ctx, tree->u.comparison.value);
                if (s == NULL) return NULL;
                ret = talloc_asprintf(mem_ctx, "(%s>=%s)", 
-                                     tree->u.equality.attr, s);
+                                     tree->u.comparison.attr, s);
                talloc_free(s);
                return ret;
        case LDB_OP_LESS:
-               s = ldb_binary_encode(mem_ctx, tree->u.equality.value);
+               s = ldb_binary_encode(mem_ctx, tree->u.comparison.value);
                if (s == NULL) return NULL;
                ret = talloc_asprintf(mem_ctx, "(%s<=%s)", 
-                                     tree->u.equality.attr, s);
+                                     tree->u.comparison.attr, s);
                talloc_free(s);
                return ret;
        case LDB_OP_PRESENT:
                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);
+               s = ldb_binary_encode(mem_ctx, tree->u.comparison.value);
                if (s == NULL) return NULL;
                ret = talloc_asprintf(mem_ctx, "(%s~=%s)", 
-                                     tree->u.equality.attr, s);
+                                     tree->u.comparison.attr, s);
                talloc_free(s);
                return ret;
        case LDB_OP_EXTENDED:
@@ -895,11 +895,15 @@ static int parse_tree_attr_replace(struct ldb_parse_tree *tree, void *private_co
        struct parse_tree_attr_replace_ctx *ctx = private_context;
        switch (tree->operation) {
        case LDB_OP_EQUALITY:
+               if (ldb_attr_cmp(tree->u.equality.attr, ctx->attr) == 0) {
+                       tree->u.equality.attr = ctx->replace;
+               }
+               break;
        case LDB_OP_GREATER:
        case LDB_OP_LESS:
        case LDB_OP_APPROX:
-               if (ldb_attr_cmp(tree->u.equality.attr, ctx->attr) == 0) {
-                       tree->u.equality.attr = ctx->replace;
+               if (ldb_attr_cmp(tree->u.comparison.attr, ctx->attr) == 0) {
+                       tree->u.comparison.attr = ctx->replace;
                }
                break;
        case LDB_OP_SUBSTRING:
index d0919845f70e009550dad6b3ef616f0527e354ea..e86e29a492dfe40e096545821c187e37a94efae6 100644 (file)
@@ -546,6 +546,7 @@ static bool ldb_parse_tree_check_splittable(const struct ldb_parse_tree *tree)
 /* Collect a list of attributes required to match a given parse tree. */
 static int ldb_parse_tree_collect_attrs(struct ldb_module *module, void *mem_ctx, const char ***attrs, const struct ldb_parse_tree *tree)
 {
+       const char *attr = NULL;
        const char **new_attrs;
        unsigned int i;
        int ret;
@@ -570,7 +571,11 @@ static int ldb_parse_tree_collect_attrs(struct ldb_module *module, void *mem_ctx
                return ldb_parse_tree_collect_attrs(module, mem_ctx, attrs, tree->u.isnot.child);
 
        default:                        /* single attribute in tree */
-               new_attrs = ldb_attr_list_copy_add(mem_ctx, *attrs, tree->u.equality.attr);
+               attr = ldb_parse_tree_get_attr(tree);
+               new_attrs = ldb_attr_list_copy_add(mem_ctx, *attrs, attr);
+               if (new_attrs == NULL) {
+                       return ldb_module_oom(module);
+               }
                talloc_free(*attrs);
                *attrs = new_attrs;
                return 0;