diff options
author | Andrew Bartlett <abartlet@samba.org> | 2016-06-15 16:11:28 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2016-06-27 00:18:17 +0200 |
commit | ab4cd63e102c6ef9e4fa9af83b7c763a5e901a40 (patch) | |
tree | 52f3550c87a45c7e6972296cf917febc7f02384e | |
parent | 4304eac85437d72f4aed36fc7797004cd97fbc9a (diff) | |
download | samba-ab4cd63e102c6ef9e4fa9af83b7c763a5e901a40.tar.gz |
ldb: Allow repl_meta_data to override the O(^2) loop checking for duplciates
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_tdb.c | 24 |
1 files changed, 16 insertions, 8 deletions
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; j<el->num_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; j<el->num_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; + } } } |