summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-10-15 15:17:52 -0700
committerRich Megginson <rmeggins@redhat.com>2010-10-15 16:56:42 -0600
commit577d0067856879a2c38be0e9324108ce45b6d686 (patch)
tree596be98360b508348880b569969bd501129124f5
parentfc52c78f1f47371fec6f8cfd16ae491d89db0eae (diff)
downloadds-577d0067856879a2c38be0e9324108ce45b6d686.tar.gz
ds-577d0067856879a2c38be0e9324108ce45b6d686.tar.xz
ds-577d0067856879a2c38be0e9324108ce45b6d686.zip
Bug 643532 - Incorrect DNs sometimes returned on searches
https://bugzilla.redhat.com/show_bug.cgi?id=643532 Description: Some of the functions in ldbm_entryrdn.c uses static memory for reading data from the entryrdn index, where the static initializer should not have been used since the memory cannot be shared among threads. This patch fixes it. (cherry picked from commit f39aab7b4fc39a2c0797424314cfc638c33f482e)
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 36fbe933..4b2bad1e 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -1006,7 +1006,6 @@ entryrdn_lookup_dn(backend *be,
DBC *cursor = NULL;
DB_TXN *db_txn = (txn != NULL) ? txn->back_txn_txn : NULL;
DBT key, data;
- static char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
char *keybuf = NULL;
Slapi_RDN *srdn = NULL;
char *orignrdn = NULL;
@@ -1064,10 +1063,7 @@ entryrdn_lookup_dn(backend *be,
/* Setting the bulk fetch buffer */
memset(&data, 0, sizeof(data));
- data.ulen = sizeof(buffer);
- data.size = sizeof(buffer);
- data.data = buffer;
- data.flags = DB_DBT_USERMEM;
+ data.flags = DB_DBT_MALLOC;
do {
/* Setting up a key for the node to get its parent */
@@ -1131,6 +1127,7 @@ retry_get1:
workid = id_stored_to_internal(elem->rdn_elem_id);
/* 1 is byref, and the dup'ed rdn is freed with srdn */
slapi_rdn_add_rdn_to_all_rdns(srdn, slapi_ch_strdup(RDN_ADDR(elem)), 1);
+ slapi_ch_free(&data.data);
} while (workid);
if (0 == workid) {
@@ -1138,6 +1135,7 @@ retry_get1:
}
bail:
+ slapi_ch_free(&data.data);
/* Close the cursor */
if (cursor) {
int myrc = cursor->c_close(cursor);
@@ -1764,7 +1762,7 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
char *keybuf = NULL;
char *realkeybuf = NULL;
DBT realkey;
- static char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
+ char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
DBT data;
DBT moddata;
rdn_elem **childelems = NULL;
@@ -2679,7 +2677,7 @@ _entryrdn_index_read(backend *be,
/* get the child elems */
if (childelems) {
- static char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
+ char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
slapi_ch_free_string(&keybuf);
keybuf = slapi_ch_smprintf("%c%u:%s", RDN_INDEX_CHILD, id, nrdn);
@@ -2768,7 +2766,7 @@ _entryrdn_append_childidl(DBC *cursor,
/* E.g., C5:ou=accounting */
char *keybuf = slapi_ch_smprintf("%c%u:%s", RDN_INDEX_CHILD, id, nrdn);
DBT key, data;
- static char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
+ char buffer[RDN_BULK_FETCH_BUFFER_SIZE];
int rc = 0;
key.data = keybuf;