summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-08 03:44:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:48 -0500
commitd2c7b5cd338d41f9b47113ec21b36a12fe10c3fc (patch)
tree13d91caef1d9ccb99b2c482341e5b659c222b066 /source4/lib
parent810831434a03b68064476124828e607bd367d98d (diff)
downloadsamba-d2c7b5cd338d41f9b47113ec21b36a12fe10c3fc.tar.gz
samba-d2c7b5cd338d41f9b47113ec21b36a12fe10c3fc.tar.bz2
samba-d2c7b5cd338d41f9b47113ec21b36a12fe10c3fc.zip
r583: fixed two bugs in the handling of index entry deletion
(This used to be commit 7b5f3370e6c078bf506ac3eb24fb330d4aee7688)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c19
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c2
2 files changed, 13 insertions, 8 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 0e9f3e3c55..3febdaa711 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -77,11 +77,11 @@ static char *ldb_dn_key(struct ldb_context *ldb,
see if a attribute value is in the list of indexed attributes
*/
static int ldb_msg_find_idx(const struct ldb_message *msg, const char *attr,
- int *v_idx)
+ int *v_idx, const char *key)
{
int i, j;
for (i=0;i<msg->num_elements;i++) {
- if (ldb_attr_cmp(msg->elements[i].name, LTDB_IDXATTR) == 0) {
+ if (ldb_attr_cmp(msg->elements[i].name, key) == 0) {
const struct ldb_message_element *el =
&msg->elements[i];
for (j=0;j<el->num_values;j++) {
@@ -127,7 +127,7 @@ static int ltdb_index_dn_simple(struct ldb_context *ldb,
/* if the attribute isn't in the list of indexed attributes then
this node needs a full search */
- if (ldb_msg_find_idx(index_list, tree->u.simple.attr, NULL) == -1) {
+ if (ldb_msg_find_idx(index_list, tree->u.simple.attr, NULL, LTDB_IDXATTR) == -1) {
return -1;
}
@@ -711,7 +711,8 @@ int ltdb_index_add(struct ldb_context *ldb, const struct ldb_message *msg)
}
for (i=0;i<msg->num_elements;i++) {
- ret = ldb_msg_find_idx(&ltdb->cache.indexlist, msg->elements[i].name, NULL);
+ ret = ldb_msg_find_idx(&ltdb->cache.indexlist, msg->elements[i].name,
+ NULL, LTDB_IDXATTR);
if (ret == -1) {
continue;
}
@@ -751,13 +752,14 @@ static int ltdb_index_del1(struct ldb_context *ldb, const char *dn,
if (ret == 0) {
/* it wasn't indexed. Did we have an earlier error? If we did then
its gone now */
- ltdb_search_dn1_free(ldb, &msg);
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: dn_key %s was not indexed\n", dn_key);
ldb_free(ldb, dn_key);
return 0;
}
- i = ldb_msg_find_idx(&msg, dn, &j);
+ i = ldb_msg_find_idx(&msg, dn, &j, LTDB_IDX);
if (i == -1) {
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: dn %s not found in %s\n", dn, dn_key);
/* it ain't there. hmmm */
ltdb_search_dn1_free(ldb, &msg);
ldb_free(ldb, dn_key);
@@ -767,7 +769,7 @@ static int ltdb_index_del1(struct ldb_context *ldb, const char *dn,
if (j != msg.elements[i].num_values - 1) {
memmove(&msg.elements[i].values[j],
&msg.elements[i].values[j+1],
- (msg.elements[i].num_values-1) *
+ (msg.elements[i].num_values-(j+1)) *
sizeof(msg.elements[i].values[0]));
}
msg.elements[i].num_values--;
@@ -800,7 +802,8 @@ int ltdb_index_del(struct ldb_context *ldb, const struct ldb_message *msg)
}
for (i=0;i<msg->num_elements;i++) {
- ret = ldb_msg_find_idx(&ltdb->cache.indexlist, msg->elements[i].name, NULL);
+ ret = ldb_msg_find_idx(&ltdb->cache.indexlist, msg->elements[i].name,
+ NULL, LTDB_IDXATTR);
if (ret == -1) {
continue;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 60eaf3117c..e2c83202e9 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -257,6 +257,8 @@ int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message
int ret;
TDB_DATA tdb_key, tdb_data, tdb_data2;
+ memset(msg, 0, sizeof(*msg));
+
/* form the key */
tdb_key = ltdb_key(ldb, dn);
if (!tdb_key.dptr) {