Handle unknown attributes in SLAPI_SEARCH_ATTRS

This commit is contained in:
Luke Howard 2006-06-09 15:54:59 +00:00
parent ea45b5b322
commit 2941bd8a9e
2 changed files with 13 additions and 11 deletions

View file

@ -1098,7 +1098,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
break;
case SLAPI_SEARCH_ATTRS: {
AttributeName *an = NULL;
size_t i = 0;
size_t i = 0, j = 0;
char **attrs = (char **)value;
PBLOCK_ASSERT_OP( pb, 0 );
@ -1122,18 +1122,20 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
;
}
if ( i ) {
an = (AttributeName *)pb->pb_op->o_tmpalloc( (i + 1) *
an = (AttributeName *)pb->pb_op->o_tmpcalloc( i + 1,
sizeof(AttributeName), pb->pb_op->o_tmpmemctx );
for ( i = 0; attrs[i] != NULL; i++ ) {
an[i].an_desc = NULL;
an[i].an_oc = NULL;
an[i].an_oc_exclude = 0;
an[i].an_name.bv_val = attrs[i];
an[i].an_name.bv_len = strlen( attrs[i] );
slap_bv2ad( &an[i].an_name, &an[i].an_desc, &pb->pb_rs->sr_text );
an[j].an_desc = NULL;
an[j].an_oc = NULL;
an[j].an_oc_exclude = 0;
an[j].an_name.bv_val = attrs[i];
an[j].an_name.bv_len = strlen( attrs[i] );
if ( slap_bv2ad( &an[j].an_name, &an[j].an_desc, &pb->pb_rs->sr_text ) == LDAP_SUCCESS ) {
j++;
}
}
an[i].an_name.bv_val = NULL;
an[i].an_name.bv_len = 0;
an[j].an_name.bv_val = NULL;
an[j].an_name.bv_len = 0;
}
pb->pb_op->ors_attrs = an;
break;

View file

@ -1377,7 +1377,7 @@ slapi_send_ldap_search_entry(
}
if ( i ) {
an = (AttributeName *) slapi_ch_malloc( (i+1) * sizeof(AttributeName) );
an = (AttributeName *) slapi_ch_calloc( i + 1, sizeof(AttributeName) );
for ( i = 0; attrs[i] != NULL; i++ ) {
an[j].an_name.bv_val = attrs[i];
an[j].an_name.bv_len = strlen( attrs[i] );