]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2023-0614 ldb: Add ldb_parse_tree_get_attr()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 3 Mar 2023 04:31:54 +0000 (17:31 +1300)
committerJule Anger <janger@samba.org>
Mon, 20 Mar 2023 09:03:38 +0000 (10:03 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_parse.c
lib/ldb/include/ldb_module.h

index f0045ad2093bbe8ac8fed75ed36ce7e84875ca5b..2d102ff750e4a06e42d5154c9784a98c80544e07 100644 (file)
@@ -997,3 +997,28 @@ struct ldb_parse_tree *ldb_parse_tree_copy_shallow(TALLOC_CTX *mem_ctx,
 
        return nt;
 }
+
+/* Get the attribute (if any) associated with the top node of a parse tree. */
+const char *ldb_parse_tree_get_attr(const struct ldb_parse_tree *tree)
+{
+       switch (tree->operation) {
+       case LDB_OP_AND:
+       case LDB_OP_OR:
+       case LDB_OP_NOT:
+               return NULL;
+       case LDB_OP_EQUALITY:
+               return tree->u.equality.attr;
+       case LDB_OP_SUBSTRING:
+               return tree->u.substring.attr;
+       case LDB_OP_GREATER:
+       case LDB_OP_LESS:
+       case LDB_OP_APPROX:
+               return tree->u.comparison.attr;
+       case LDB_OP_PRESENT:
+               return tree->u.present.attr;
+       case LDB_OP_EXTENDED:
+               return tree->u.extended.attr;
+       }
+
+       return NULL;
+}
index 4ae381ba5bead14b4c214942612735fb67246bcb..bd369ed95123122eb4b6cfadb01331dd7b7cecc1 100644 (file)
@@ -490,6 +490,9 @@ int ldb_init_module(const char *version);
  */
 bool ldb_dn_replace_components(struct ldb_dn *dn, struct ldb_dn *new_dn);
 
+/* Get the attribute (if any) associated with the top node of a parse tree. */
+const char *ldb_parse_tree_get_attr(const struct ldb_parse_tree *tree);
+
 /*
   walk a parse tree, calling the provided callback on each node
 */