From d430fa0346b5e962d019295df9eccadeb1a2c832 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Fri, 3 Jul 2009 14:29:40 +0000 Subject: [PATCH] error out when adding multiple olcIndex values for the same attribute (ITS#6196) --- servers/slapd/back-bdb/attr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 54cb2e4ac6..2e5a5e56d0 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -319,15 +319,20 @@ bdb_attr_index_config( if( rc ) { if ( bdb->bi_flags & BDB_IS_OPEN ) { AttrInfo *b = bdb_attr_mask( bdb, ad ); - /* If we were editing this attr, reset it */ - b->ai_indexmask &= ~BDB_INDEX_DELETING; - /* If this is leftover from a previous add, commit it */ - if ( b->ai_newmask ) - b->ai_indexmask = b->ai_newmask; - b->ai_newmask = a->ai_newmask; - ch_free( a ); - rc = 0; - continue; + /* If there is already an index defined for this attribute + * it must be replaced. Otherwise we end up with multiple + * olcIndex values for the same attribute */ + if ( b->ai_indexmask & BDB_INDEX_DELETING ) { + /* If we were editing this attr, reset it */ + b->ai_indexmask &= ~BDB_INDEX_DELETING; + /* If this is leftover from a previous add, commit it */ + if ( b->ai_newmask ) + b->ai_indexmask = b->ai_newmask; + b->ai_newmask = a->ai_newmask; + ch_free( a ); + rc = 0; + continue; + } } if (c_reply) { snprintf(c_reply->msg, sizeof(c_reply->msg), -- 2.39.5