Relax entry_header, zero-length entries are valid.

This commit is contained in:
Howard Chu 2011-08-27 14:35:31 -07:00
parent c617f3c3b9
commit 4f35d789ac
2 changed files with 26 additions and 27 deletions

View File

@ -131,6 +131,7 @@ int bdb_id2entry(
rc = entry_header( &eh );
if ( rc ) goto finish;
if ( eh.nvals ) {
/* Get the size */
data.flags ^= DB_DBT_PARTIAL;
data.ulen = 0;
@ -149,6 +150,7 @@ int bdb_id2entry(
eh.data += off;
rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
}
finish:
cursor->c_close( cursor );
@ -157,11 +159,15 @@ finish:
return rc;
}
if ( eh.nvals ) {
#ifdef SLAP_ZONE_ALLOC
rc = entry_decode(&eh, e, bdb->bi_cache.c_zctx);
#else
rc = entry_decode(&eh, e);
#endif
} else {
*e = entry_alloc();
}
if( rc == 0 ) {
(*e)->e_id = id;

View File

@ -814,18 +814,11 @@ int entry_header(EntryHeader *eh)
{
unsigned char *ptr = (unsigned char *)eh->bv.bv_val;
/* Some overlays can create empty entries
* so don't check for zeros here.
*/
eh->nattrs = entry_getlen(&ptr);
if ( !eh->nattrs ) {
Debug( LDAP_DEBUG_ANY,
"entry_header: attribute count was zero\n", 0, 0, 0);
return LDAP_OTHER;
}
eh->nvals = entry_getlen(&ptr);
if ( !eh->nvals ) {
Debug( LDAP_DEBUG_ANY,
"entry_header: value count was zero\n", 0, 0, 0);
return LDAP_OTHER;
}
eh->data = (char *)ptr;
return LDAP_SUCCESS;
}