diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-05 04:27:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:45 -0500 |
commit | 232bc1503fc0e3f85b4711f077d2566dc0f0c823 (patch) | |
tree | 14e4a2736ab44368bdb27296ddbe5fb3a05fd5fc /source4/lib/ldb/ldb_tdb/ldb_index.c | |
parent | af66c31e44bcb052f35f9b1de8e997149fddac89 (diff) | |
download | samba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.tar.gz samba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.tar.bz2 samba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.zip |
r490: - expanded the test suite to test modify and delete operations
- made yet another attempt to make ldb const clean.
- "make test" now runs both the tdb and ldap backend tests, and run the ldbtest utility
with and without indexing
- added prototypes in ldb.h for ldb_msg_*() public functions
(This used to be commit 01e87406768cb5a98ac8530a2f361a4987a36cd3)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_index.c')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index d250bc10be..0b9581e52f 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -202,7 +202,10 @@ static int ltdb_index_dn_objectclass(struct ldb_context *ldb, struct ldb_parse_tree tree2; struct dn_list list2; tree2.operation = LDB_OP_SIMPLE; - tree2.u.simple.attr = LTDB_OBJECTCLASS; + tree2.u.simple.attr = strdup(LTDB_OBJECTCLASS); + if (!tree2.u.simple.attr) { + return -1; + } tree2.u.simple.value = el->values[j]; if (ltdb_index_dn_objectclass(ldb, &tree2, index_list, &list2) == 1) { @@ -214,6 +217,7 @@ static int ltdb_index_dn_objectclass(struct ldb_context *ldb, dn_list_free(&list2); } } + free(tree2.u.simple.attr); } } } @@ -488,7 +492,7 @@ static int ldb_index_filter(struct ldb_context *ldb, struct ldb_parse_tree *tree const char *base, enum ldb_scope scope, const struct dn_list *dn_list, - const char * const attrs[], struct ldb_message ***res) + char * const attrs[], struct ldb_message ***res) { int i; unsigned int count = 0; @@ -528,7 +532,7 @@ int ltdb_search_indexed(struct ldb_context *ldb, const char *base, enum ldb_scope scope, struct ldb_parse_tree *tree, - const char * const attrs[], struct ldb_message ***res) + char * const attrs[], struct ldb_message ***res) { struct ltdb_private *ltdb = ldb->private_data; struct dn_list dn_list; @@ -569,7 +573,10 @@ static int ltdb_index_add1_new(struct ldb_context *ldb, } msg->elements = el2; - msg->elements[msg->num_elements].name = LTDB_IDX; + msg->elements[msg->num_elements].name = strdup(LTDB_IDX); + if (!msg->elements[msg->num_elements].name) { + return -1; + } msg->elements[msg->num_elements].num_values = 0; msg->elements[msg->num_elements].values = malloc_p(struct ldb_val); if (!msg->elements[msg->num_elements].values) { @@ -627,7 +634,7 @@ static int ltdb_index_add1(struct ldb_context *ldb, char *dn, { struct ldb_message msg; char *dn_key; - int ret, i; + int ret, i, added=0; dn_key = ldb_dn_key(el->name, &el->values[v_idx]); if (!dn_key) { @@ -661,6 +668,7 @@ static int ltdb_index_add1(struct ldb_context *ldb, char *dn, } if (i == msg.num_elements) { + added = 1; ret = ltdb_index_add1_new(ldb, &msg, el, dn); } else { ret = ltdb_index_add1_add(ldb, &msg, el, i, dn); @@ -670,6 +678,10 @@ static int ltdb_index_add1(struct ldb_context *ldb, char *dn, ret = ltdb_store(ldb, &msg, TDB_REPLACE); } + if (added) { + free(msg.elements[i].name); + } + ltdb_search_dn1_free(ldb, &msg); return ret; |