From: Howard Chu Date: Fri, 20 Feb 2009 02:02:17 +0000 (+0000) Subject: ITS#5959 drop illegal values, only drop attr if it's left empty X-Git-Tag: ACLCHECK_0~795 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2024d5af85e743ce7d8d7947f3257272d42a9f31;p=openldap ITS#5959 drop illegal values, only drop attr if it's left empty --- diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 861418c8e4..389278cb11 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -428,7 +428,7 @@ retry: * are passed without checks */ rc = ldap_parse_intermediate( lc->lc_ld, res, - &rs->sr_rspoid, + (char **)&rs->sr_rspoid, &rs->sr_rspdata, &rs->sr_ctrls, 0 ); @@ -439,7 +439,7 @@ retry: slap_send_ldap_intermediate( op, rs ); if ( rs->sr_rspoid != NULL ) { - ber_memfree( rs->sr_rspoid ); + ber_memfree( (char *)rs->sr_rspoid ); rs->sr_rspoid = NULL; } @@ -729,7 +729,10 @@ ldap_build_entry( goto next_attr; } - for ( i = 0; !BER_BVISNULL( &attr->a_vals[i] ); i++ ) { + for ( i = 0; !BER_BVISNULL( &attr->a_vals[i] ); i++ ) ; + last = i; + + for ( i = 0; isoc_cname ); } else { - attr->a_nvals = NULL; - attr_free( attr ); - goto next_attr; + LBER_FREE( attr->a_vals[i].bv_val ); + if ( --last == i ) { + BER_BVZERO( &attr->a_vals[i] ); + break; + } + attr->a_vals[i] = attr->a_vals[last]; + BER_BVZERO( &attr->a_vals[last] ); } - } - - if ( pretty ) { + } else if ( pretty ) { LBER_FREE( attr->a_vals[i].bv_val ); attr->a_vals[i] = pval; } } attr->a_numvals = last = i; + if ( last == 0 && attr->a_vals != &slap_dummy_bv ) { + attr->a_nvals = NULL; + attr_free( attr ); + goto next_attr; + } if ( last && attr->a_desc->ad_type->sat_equality && attr->a_desc->ad_type->sat_equality->smr_normalize ) @@ -784,16 +794,26 @@ ldap_build_entry( NULL ); if ( rc != LDAP_SUCCESS ) { - BER_BVZERO( &attr->a_nvals[i] ); - attr_free( attr ); - goto next_attr; + LBER_FREE( attr->a_vals[i].bv_val ); + if ( --last == i ) { + BER_BVZERO( &attr->a_vals[i] ); + break; + } + attr->a_vals[i] = attr->a_vals[last]; + BER_BVZERO( &attr->a_vals[last] ); } } BER_BVZERO( &attr->a_nvals[i] ); + if ( last == 0 ) { + attr_free( attr ); + goto next_attr; + } } else { attr->a_nvals = attr->a_vals; } + + attr->a_numvals = last; *attrp = attr; attrp = &attr->a_next;