]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/search.c
clarify generated password issue
[openldap] / servers / slapd / back-ldap / search.c
index 8ddd2155c41862a57e5043707584c5e0ecb3d1c2..166e360d71e3ccc922d81d8a813f2f832363c4c0 100644 (file)
@@ -216,7 +216,6 @@ retry:
                        op->ors_slimit, &msgid );
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
-fail:;
                switch ( rs->sr_err ) {
                case LDAP_SERVER_DOWN:
                        if ( do_retry ) {
@@ -259,7 +258,7 @@ fail:;
         * but this is necessary for version matching, and for ACL processing.
         */
 
-       for ( rc = 0; rc != -1; rc = ldap_result( lc->lc_ld, msgid, 0, &tv, &res ) )
+       for ( rc = 0; rc != -1; rc = ldap_result( lc->lc_ld, msgid, LDAP_MSG_ONE, &tv, &res ) )
        {
                /* check for abandon */
                if ( op->o_abandon ) {
@@ -287,7 +286,6 @@ fail:;
                } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
                        Entry           ent = { 0 };
                        struct berval   bdn = BER_BVNULL;
-                       int             abort = 0;
 
                        do_retry = 0;
 
@@ -298,21 +296,25 @@ fail:;
                                rs->sr_attrs = op->ors_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_flags = 0;
-                               abort = send_search_entry( op, rs );
+                               rc = rs->sr_err = send_search_entry( op, rs );
                                if ( !BER_BVISNULL( &ent.e_name ) ) {
                                        assert( ent.e_name.bv_val != bdn.bv_val );
-                                       free( ent.e_name.bv_val );
+                                       op->o_tmpfree( ent.e_name.bv_val, op->o_tmpmemctx );
                                        BER_BVZERO( &ent.e_name );
                                }
                                if ( !BER_BVISNULL( &ent.e_nname ) ) {
-                                       free( ent.e_nname.bv_val );
+                                       op->o_tmpfree( ent.e_nname.bv_val, op->o_tmpmemctx );
                                        BER_BVZERO( &ent.e_nname );
                                }
                                entry_clean( &ent );
                        }
                        ldap_msgfree( res );
-                       if ( abort ) {
-                               ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
+                       if ( rc != LDAP_SUCCESS ) {
+                               if ( rc == LDAP_UNAVAILABLE ) {
+                                       rc = rs->sr_err = LDAP_OTHER;
+                               } else {
+                                       ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
+                               }
                                goto finish;
                        }
 
@@ -403,13 +405,22 @@ fail:;
                        }
 
                        if ( match.bv_val != NULL ) {
+#ifndef LDAP_NULL_IS_NULL
                                if ( match.bv_val[ 0 ] == '\0' ) {
                                        LDAP_FREE( match.bv_val );
                                        BER_BVZERO( &match );
-                               } else {
+                               } else
+#endif /* LDAP_NULL_IS_NULL */
+                               {
                                        match.bv_len = strlen( match.bv_val );
                                }
                        }
+#ifndef LDAP_NULL_IS_NULL
+                       if ( rs->sr_text != NULL && rs->sr_text[ 0 ] == '\0' ) {
+                               LDAP_FREE( (char *)rs->sr_text );
+                               rs->sr_text = NULL;
+                       }
+#endif /* LDAP_NULL_IS_NULL */
 
                        /* cleanup */
                        if ( references ) {