]> git.sur5r.net Git - openldap/commitdiff
ITS#5959 just drop illegal values, keep remainder if any. fix a_numvals.
authorHoward Chu <hyc@openldap.org>
Fri, 20 Feb 2009 01:48:19 +0000 (01:48 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 20 Feb 2009 01:48:19 +0000 (01:48 +0000)
servers/slapd/back-meta/search.c

index 4c52831e2326c4e8dccd25d25671712202b5a9dc..b82a8429d503c31eff8e3e1f7a0cfae905ae26cd 100644 (file)
@@ -2080,24 +2080,34 @@ remove_oc:;
 
                        attr->a_nvals = ch_malloc( ( last + 1 ) * sizeof( struct berval ) );
                        for ( i = 0; i<last; i++ ) {
-                               /* if normalizer fails, forget this attr */
+                               /* if normalizer fails, drop this value */
                                if ( attr->a_desc->ad_type->sat_equality->smr_normalize(
                                        SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
                                        attr->a_desc->ad_type->sat_syntax,
                                        attr->a_desc->ad_type->sat_equality,
                                        &attr->a_vals[i], &attr->a_nvals[i],
                                        NULL )) {
-                                       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] );
+                                       i--;
                                }
                        }
+                       if ( last == 0 && attr->a_vals != &slap_dummy_bv ) {
+                               attr_free( attr );
+                               goto next_attr;
+                       }
                        BER_BVZERO( &attr->a_nvals[i] );
 
                } else {
                        attr->a_nvals = attr->a_vals;
                }
 
+               attr->a_numvals = last;
                *attrp = attr;
                attrp = &attr->a_next;
 next_attr:;