]> git.sur5r.net Git - openldap/commitdiff
More for ITS#5959
authorQuanah Gibson-Mount <quanah@openldap.org>
Fri, 20 Feb 2009 02:15:05 +0000 (02:15 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Fri, 20 Feb 2009 02:15:05 +0000 (02:15 +0000)
CHANGES
servers/slapd/back-ldap/search.c
servers/slapd/back-meta/search.c

diff --git a/CHANGES b/CHANGES
index c3c80134400ab83cb974e60e277abac6f457e6a4..c83f6a28464f3a5aff33a3f435bcd4b91c03cceb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,7 +7,7 @@ OpenLDAP 2.4.15 Release (2009/02/19)
        Fixed slapd corrupt contextCSN (ITS#5947)
        Fixed slapd syncrepl order to match on add/delete (ITS#5954)
        Fixed slapd-bdb/hdb behavior with unallocatable shm (ITS#5956)
-       Fixed slapd-meta with entries with invalid attrs (ITS#5959)
+       Fixed slapd-ldap/meta with entries with invalid attrs (ITS#5959)
        Fixed slapd-relay control initialization (ITS#5724)
        Fixed slapo-pcache caching invalid entries (ITS#5927)
        Fixed slapo-rwm objectClass preservation (ITS#5760)
index 861418c8e4e5f2e6948ce70cb5cf19e4c856e5e7..389278cb11321e5145729c81e3651e80cad6806d 100644 (file)
@@ -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; i<last; i++ ) {
                        struct berval   pval;
                        int             rc;
 
@@ -752,18 +755,25 @@ ldap_build_entry(
                                        ber_dupbv( &pval, &oc->soc_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;
 
index 4c52831e2326c4e8dccd25d25671712202b5a9dc..a094de66edd0d774d5cc49958bd9fc6b20b45ecd 100644 (file)
@@ -1222,7 +1222,7 @@ really_bad:;
                                         * are passed without checks */
                                        rs->sr_err = ldap_parse_intermediate( msc->msc_ld,
                                                msg,
-                                               &rs->sr_rspoid,
+                                               (char **)&rs->sr_rspoid,
                                                &rs->sr_rspdata,
                                                &rs->sr_ctrls,
                                                0 );
@@ -1236,7 +1236,7 @@ really_bad:;
                                        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;
                                        }
 
@@ -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--;
                                }
                        }
                        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;
 next_attr:;