diff options
author | Nadezhda Ivanova <nivanova@symas.com> | 2013-09-18 15:31:24 -0700 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2014-07-15 12:46:13 +0200 |
commit | 540dd6fa50aafa672c94085ab7b0dc85b38061b8 (patch) | |
tree | 38dd2e56d0475241ad036f064c82f2dbdbcc184c /lib | |
parent | cdd4ef63198b1b75e37a1ed6cc83275d5790ec64 (diff) | |
download | samba-540dd6fa50aafa672c94085ab7b0dc85b38061b8.tar.gz |
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>
(cherry picked from commit 75705776929d87f1a694582261c07d1724574370)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/ldb_map/ldb_map_outbound.c | 22 |
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; |