From 19a13cbe0681b3996c33f7449f69b0fb0dc5d640 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Sat, 6 Jul 2019 23:24:43 +1200 Subject: [PATCH] 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 Reviewed-by: Gary Lockyer --- lib/ldb/common/ldb_dn.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.47.3