summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-10 17:23:00 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-10 17:51:30 +1100
commitc59372b0b87ca85c1b9061545b6714f00736bb35 (patch)
tree9bf83aa4c8c96788d67cb090d7402c8f2f94e71f /source4/lib/ldb/common
parent62dc7f6b2dd7df83740e4761988eb2f87205c73c (diff)
downloadsamba-c59372b0b87ca85c1b9061545b6714f00736bb35.tar.gz
samba-c59372b0b87ca85c1b9061545b6714f00736bb35.tar.bz2
samba-c59372b0b87ca85c1b9061545b6714f00736bb35.zip
s4-ldb: fixed 2 bugs in ldb_dn_set_extended_component()
The first bug was that setting a component twice could cause it to appear twice in the DN. The second bug was that using an existing ldb_val from a previous call of ldb_dn_get_extended_component() as an argument to ldb_dn_set_extended_component() would cause a valgrind error (as the array the val pointed into will change).
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 63cec89953..59a6dc0594 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -1855,6 +1855,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
{
struct ldb_dn_ext_component *p;
int i;
+ struct ldb_val v2;
if ( ! ldb_dn_validate(dn)) {
return LDB_ERR_OTHER;
@@ -1878,7 +1879,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
ldb_dn_mark_invalid(dn);
return LDB_ERR_OPERATIONS_ERROR;
}
-
+ return LDB_SUCCESS;
} else {
if (i != (dn->ext_comp_num - 1)) {
memmove(&dn->ext_components[i],
@@ -1906,6 +1907,8 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
return LDB_SUCCESS;
}
+ v2 = *val;
+
p = dn->ext_components
= talloc_realloc(dn,
dn->ext_components,
@@ -1916,7 +1919,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
return LDB_ERR_OPERATIONS_ERROR;
}
- p[dn->ext_comp_num].value = ldb_val_dup(dn->ext_components, val);
+ p[dn->ext_comp_num].value = ldb_val_dup(dn->ext_components, &v2);
p[dn->ext_comp_num].name = talloc_strdup(p, name);
if (!dn->ext_components[i].name || !dn->ext_components[i].value.data) {