From 54e092bb31001879f4d7a49e36a226c27b4d9843 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 16 May 2013 13:52:51 +1000 Subject: [PATCH] dsdb-linked_attributes: Do not crash if the target GUID can not be found Note that we must not give an error when we cannot find the object that should hold the backlink, there really isn't anything we can do in this case. Andrew Bartlett Reviewed-by: Stefan Metzmacher --- source4/dsdb/samdb/ldb_modules/linked_attributes.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index a55ec87f0fd..eb57f91e6d8 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -4,6 +4,7 @@ Copyright (C) Andrew Bartlett 2007 Copyright (C) Simo Sorce 2008 Copyright (C) Matthieu Patou 2011 + Copyright (C) Andrew Tridgell 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -729,6 +730,20 @@ static int linked_attributes_fix_links(struct ldb_module *module, talloc_free(tmp_ctx); return ret; } + if (res->count == 0) { + /* Forward link without backlink object remaining - nothing to do here */ + continue; + } + if (res->count != 1) { + ldb_asprintf_errstring(ldb, "Linked attribute %s->%s between %s and %s - target GUID %s found more than once!", + el->name, target->lDAPDisplayName, + ldb_dn_get_linearized(old_dn), + ldb_dn_get_linearized(dsdb_dn->dn), + GUID_string(tmp_ctx, &link_guid)); + talloc_free(tmp_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + msg = res->msgs[0]; if (msg->num_elements == 0) { -- 2.11.4.GIT