summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2019-07-06 23:24:43 +1200
committerKarolin Seeger <kseeger@samba.org>2019-09-04 08:31:24 +0000
commit0358b3f9bc1e557a639ec63670d8c29c135e54f5 (patch)
tree90cb7bdbf1e41871173fa3b6381a43a25dae8330 /lib
parent0e96b2cb506f278562fe21b0b8d47da276b939c6 (diff)
downloadsamba-0358b3f9bc1e557a639ec63670d8c29c135e54f5.tar.gz
ldb: do not allow adding a DN as a base to itself
If you try to add a dn to itself, it expands as it goes. The resulting loop cannot end well. It looks like this in Python: dn = ldb.Dn(ldb.Ldb(), 'CN=y,DC=x') dn.add_base(dn) Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 19a13cbe0681b3996c33f7449f69b0fb0dc5d640)
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/common/ldb_dn.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c
index 2e98f391467..eccb4a0ce4b 100644
--- a/lib/ldb/common/ldb_dn.c
+++ b/lib/ldb/common/ldb_dn.c
@@ -1357,6 +1357,10 @@ bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base)
return false;
}
+ if (dn == base) {
+ return false; /* or we will visit infinity */
+ }
+
if (dn->components) {
unsigned int i;