From: Andrew Bartlett Date: Wed, 15 Jun 2016 04:11:28 +0000 (+1200) Subject: ldb: Allow repl_meta_data to override the O(^2) loop checking for duplciates X-Git-Tag: tdb-1.3.10~700 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab4cd63e102c6ef9e4fa9af83b7c763a5e901a40;p=thirdparty%2Fsamba.git ldb: Allow repl_meta_data to override the O(^2) loop checking for duplciates Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 6a91f053f64..1a4f4cad4c4 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -858,14 +858,22 @@ int ltdb_modify_internal(struct ldb_module *module, goto done; } - /* TODO: This is O(n^2) - replace with more efficient check */ - for (j=0; jnum_values; j++) { - if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(ldb, - "attribute '%s': value #%u on '%s' provided more than once", - el->name, j, ldb_dn_get_linearized(msg2->dn)); - ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; - goto done; + /* + * We don't need to check this if we have been + * pre-screened by the repl_meta_data module + * in Samba, or someone else who can claim to + * know what they are doing. + */ + if (!(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { + /* TODO: This is O(n^2) - replace with more efficient check */ + for (j=0; jnum_values; j++) { + if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { + ldb_asprintf_errstring(ldb, + "attribute '%s': value #%u on '%s' provided more than once", + el->name, j, ldb_dn_get_linearized(msg2->dn)); + ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; + goto done; + } } }