#ifdef BDB_IDL_MULTI
{
DBC *cursor;
- ID buf[BDB_PAGESIZE*4];
+ /* buf must be large enough to grab the entire IDL in one
+ * get(), otherwise BDB 4 will leak resources on subsequent
+ * get's. We can safely call get() twice - once for the data,
+ * and once to get the DB_NOTFOUND result meaning there's
+ * no more data. See ITS#2040 for details.
+ */
+ ID buf[BDB_IDL_DB_SIZE*5];
ID *i;
void *ptr;
size_t len;
err = "c_count";
goto fail;
}
- if ( count >= BDB_IDL_DB_SIZE ) {
+ if ( count >= BDB_IDL_DB_MAX ) {
/* No room, convert to a range */
DBT key2 = *key;
/* store the key */
rc = db->put( db, tid, key, &data, 0 );
#endif
- if( rc == DB_KEYEXIST ) rc = 0;
-
- if( rc != 0 ) {
+ if( rc != 0 && rc != DB_KEYEXIST ) {
#ifdef NEW_LOGGING
LDAP_LOG( INDEX, ERR,
"bdb_idl_insert_key: put failed: %s (%d)\n",
}
if ( BDB_IDL_IS_RANGE( a ) || BDB_IDL_IS_RANGE(b) ) {
-over: a[1] = IDL_MIN( BDB_IDL_FIRST(a), BDB_IDL_FIRST(b) );
- a[2] = IDL_MAX( BDB_IDL_LAST(a), BDB_IDL_LAST(b) );
+over: ida = IDL_MIN( BDB_IDL_FIRST(a), BDB_IDL_FIRST(b) );
+ idb = IDL_MAX( BDB_IDL_LAST(a), BDB_IDL_LAST(b) );
+ a[0] = NOID;
+ a[1] = ida;
+ a[2] = idb;
return 0;
}
while( ida != NOID || idb != NOID ) {
if ( ida < idb ) {
if( ++cursorc > BDB_IDL_UM_MAX ) {
- a[0] = NOID;
goto over;
}
b[cursorc] = ida;
idb = NOID;
else
idb = b[cursorc];
- if (b[cursorb] < idb)
+ if (cursorb <= b[0] && b[cursorb] < idb)
a[cursora++] = b[cursorb++];
else {
a[cursora++] = idb;