]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/search.c
better fix: in case of error during bind, just bail out (very conservative, though)
[openldap] / servers / slapd / back-meta / search.c
index 1f1408d19c49b3c8a2054f4e2385cbff347f200d..7adabf379e60ba2ffc5684ddf950c378efecec1e 100644 (file)
@@ -244,8 +244,9 @@ meta_back_search( Operation *op, SlapReply *rs )
        LDAPMessage     *res = NULL, *e;
        int             rc = 0, sres = LDAP_SUCCESS;
        char            *matched = NULL;
-       int             i, last = 0, ncandidates = 0,
+       int             last = 0, ncandidates = 0,
                        initial_candidates = 0, candidate_match = 0;
+       long            i;
        dncookie        dc;
        int             is_ok = 0;
        void            *savepriv;
@@ -357,7 +358,6 @@ meta_back_search( Operation *op, SlapReply *rs )
 
        if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
                stoptime = op->o_time + op->ors_tlimit;
-               tv.tv_sec = 0;
        }
 
        /*
@@ -630,11 +630,11 @@ really_bad:;
                                sres = slap_map_api2result( rs );
 
                                snprintf( buf, sizeof( buf ),
-                                       "%s meta_back_search[%d] "
-                                       "match=\"%s\" err=%d\n",
+                                       "%s meta_back_search[%ld] "
+                                       "match=\"%s\" err=%ld\n",
                                        op->o_log_prefix, i,
                                        candidates[ i ].sr_matched ? candidates[ i ].sr_matched : "",
-                                       candidates[ i ].sr_err );
+                                       (long) candidates[ i ].sr_err );
                                Debug( LDAP_DEBUG_ANY, "%s", buf, 0, 0 );
 
                                switch ( sres ) {
@@ -702,8 +702,7 @@ really_bad:;
                }
 
                if ( gotit == 0 ) {
-                       tv.tv_sec = 0;
-                        tv.tv_usec = 100000;   /* 0.1 s */
+                       LDAP_BACK_TV_SET( &tv );
                         ldap_pvt_thread_yield();
 
                } else {
@@ -726,7 +725,7 @@ really_bad:;
         * FIXME: only the last one gets caught!
         */
        savepriv = op->o_private;
-       op->o_private = (void *)mi->mi_ntargets;
+       op->o_private = (void *)(long)mi->mi_ntargets;
        if ( candidate_match > 0 ) {
                struct berval   pmatched = BER_BVNULL;
 
@@ -929,13 +928,10 @@ meta_send_entry(
                if ( BER_BVISNULL( &mapped ) || mapped.bv_val[0] == '\0' ) {
                        continue;
                }
-               attr = ( Attribute * )ch_malloc( sizeof( Attribute ) );
+               attr = ( Attribute * )ch_calloc( 1, sizeof( Attribute ) );
                if ( attr == NULL ) {
                        continue;
                }
-               attr->a_flags = 0;
-               attr->a_next = 0;
-               attr->a_desc = NULL;
                if ( slap_bv2ad( &mapped, &attr->a_desc, &text )
                                != LDAP_SUCCESS) {
                        if ( slap_bv2undef_ad( &mapped, &attr->a_desc, &text,
@@ -991,7 +987,6 @@ meta_send_entry(
                pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
 
                if ( !validate && !pretty ) {
-                       attr->a_nvals = NULL;
                        attr_free( attr );
                        goto next_attr;
                }
@@ -1030,16 +1025,18 @@ meta_send_entry(
                 * ACLs to the target directory server, and letting
                 * everything pass thru the ldap backend.
                 */
-               } else if ( attr->a_desc->ad_type->sat_syntax ==
+               } else {
+                       int     i;
+
+                       if ( attr->a_desc->ad_type->sat_syntax ==
                                slap_schema.si_syn_distinguishedName )
-               {
-                       ldap_dnattr_result_rewrite( &dc, attr->a_vals );
+                       {
+                               ldap_dnattr_result_rewrite( &dc, attr->a_vals );
 
-               } else if ( attr->a_desc == slap_schema.si_ad_ref ) {
-                       ldap_back_referral_result_rewrite( &dc, attr->a_vals );
+                       } else if ( attr->a_desc == slap_schema.si_ad_ref ) {
+                               ldap_back_referral_result_rewrite( &dc, attr->a_vals );
 
-               } else {
-                       int     i;
+                       }
 
                        for ( i = 0; i < last; i++ ) {
                                struct berval   pval;
@@ -1072,9 +1069,8 @@ meta_send_entry(
                                }
                        }
 
-                       if ( last == 0 ) {
-                               ch_free( attr->a_vals );
-                               ch_free( attr );
+                       if ( last == 0 && attr->a_vals != &slap_dummy_bv ) {
+                               attr_free( attr );
                                goto next_attr;
                        }
                }