From: Joseph Sutton Date: Tue, 14 Feb 2023 01:18:45 +0000 (+1300) Subject: ldb: Use correct member of union X-Git-Tag: talloc-2.4.1~1059 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2bbb47a7ce33c53e74744dae386a0c158b2cee3;p=thirdparty%2Fsamba.git ldb: Use correct member of union Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/common/ldb_parse.c b/lib/ldb/common/ldb_parse.c index 2d102ff750e..f1d224a255e 100644 --- a/lib/ldb/common/ldb_parse.c +++ b/lib/ldb/common/ldb_parse.c @@ -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: diff --git a/lib/ldb/ldb_map/ldb_map_outbound.c b/lib/ldb/ldb_map/ldb_map_outbound.c index d0919845f70..e86e29a492d 100644 --- a/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/lib/ldb/ldb_map/ldb_map_outbound.c @@ -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;