From: Luke Howard Date: Fri, 9 Jun 2006 15:54:59 +0000 (+0000) Subject: Handle unknown attributes in SLAPI_SEARCH_ATTRS X-Git-Tag: OPENLDAP_REL_ENG_2_4_3ALPHA~9^2~164 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2941bd8a9e8b69b32d7952ce089aea0d4ac3f245;p=openldap Handle unknown attributes in SLAPI_SEARCH_ATTRS --- diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index ea6d4edcb2..d27a32e1c2 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -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; diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 6516a68bac..73f16c9a50 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -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] );