summaryrefslogtreecommitdiff
path: root/lib/ldb/ldb_map
diff options
context:
space:
mode:
authorNadezhda Ivanova <nivanova@symas.com>2013-09-18 15:31:24 -0700
committerNadezhda Ivanova <nivanova@symas.com>2013-09-23 18:40:25 -0700
commit75705776929d87f1a694582261c07d1724574370 (patch)
treeeec43bd692ae4ed81f2dc577eafed94ed92fcef7 /lib/ldb/ldb_map
parent5805b7abc88d9f16bc927ae5d51c2807e4a939ee (diff)
downloadsamba-75705776929d87f1a694582261c07d1724574370.tar.gz
samba-75705776929d87f1a694582261c07d1724574370.tar.bz2
samba-75705776929d87f1a694582261c07d1724574370.zip
s4-openldap: Remove use of talloc_reference in ldb_map_outbound.c
Instead of referencing the values array of the element to the new element, copy them, to avoid use of talloc_reference and remove a warning of talloc_steal with reference. The issue is only relevant when openldap backend is used. Signed-off-by: Nadezhda Ivanova <nivanova@symas.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/ldb/ldb_map')
-rw-r--r--lib/ldb/ldb_map/ldb_map_outbound.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/ldb/ldb_map/ldb_map_outbound.c b/lib/ldb/ldb_map/ldb_map_outbound.c
index b6357bdca3..1ee2dfe12d 100644
--- a/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -190,7 +190,7 @@ static int map_attrs_partition(struct ldb_module *module, void *mem_ctx, const c
static int ldb_msg_replace(struct ldb_message *msg, const struct ldb_message_element *el)
{
struct ldb_message_element *old;
-
+ int j;
old = ldb_msg_find_element(msg, el->name);
/* no local result, add as new element */
@@ -198,18 +198,22 @@ static int ldb_msg_replace(struct ldb_message *msg, const struct ldb_message_ele
if (ldb_msg_add_empty(msg, el->name, 0, &old) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- talloc_free(discard_const_p(char, old->name));
+ }
+ else {
+ talloc_free(old->values);
}
- /* copy new element */
- *old = *el;
-
- /* and make sure we reference the contents */
- if (!talloc_reference(msg->elements, el->name)) {
+ old->values = talloc_array(msg->elements, struct ldb_val, el->num_values);
+ old->num_values = el->num_values;
+ if (old->values == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- if (!talloc_reference(msg->elements, el->values)) {
- return LDB_ERR_OPERATIONS_ERROR;
+ /* copy the values into the element */
+ for (j=0;j<el->num_values;j++) {
+ old->values[j] = ldb_val_dup(old->values, &el->values[j]);
+ if (old->values[j].data == NULL && el->values[j].length != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
}
return 0;