From ced3eef776dd44d0f3e9219f77e2660f9e49fa92 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 4 Dec 2009 17:45:38 +1100 Subject: s4-drsutil: fixed a memory leak in samdb_search_count In general functions that don't return any memory should not take a memory context. Otherwise it is too easy to have a bug like this where memory is leaked --- source4/dsdb/samdb/ldb_modules/operational.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/dsdb/samdb') diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c index 031544d6a8..cc29476665 100644 --- a/source4/dsdb/samdb/ldb_modules/operational.c +++ b/source4/dsdb/samdb/ldb_modules/operational.c @@ -104,7 +104,10 @@ static int construct_primary_group_token(struct ldb_module *module, ldb = ldb_module_get_ctx(module); - if (samdb_search_count(ldb, ldb, msg->dn, "(objectclass=group)") == 1) { + /* this is horrendously inefficient! we're doing a subtree + * search for every DN we return. So that's N^2 in the + * total number of objects! */ + if (samdb_search_count(ldb, msg->dn, "(objectclass=group)") == 1) { primary_group_token = samdb_result_rid_from_sid(ldb, msg, "objectSid", 0); return samdb_msg_add_int(ldb, ldb, msg, "primaryGroupToken", -- cgit