Skip to content

Commit

Permalink
ldb: Allow repl_meta_data to override the O(^2) loop checking for dup…
Browse files Browse the repository at this point in the history
…lciates

Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Garming Sam <[email protected]>
  • Loading branch information
abartlet committed Jun 26, 2016
1 parent 4304eac commit ab4cd63
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/ldb/ldb_tdb/ldb_tdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit ab4cd63

Please sign in to comment.