]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/modify.c
Fix negative caching again, be sure it's really from zero entries returned
[openldap] / servers / slapd / modify.c
index e38aa8700708092ea3e4ff5ecc2bed19fed773e3..44f67247c7a0b885062fda956088982e36b78356 100644 (file)
@@ -214,7 +214,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
        Modifications   *tmp;
 #endif
        int             manageDSAit;
-       BackendDB       *op_be;
+       BackendDB       *op_be, *bd = op->o_bd;
        char            textbuf[ SLAP_TEXT_BUFLEN ];
        size_t          textlen = sizeof( textbuf );
        
@@ -302,6 +302,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
         */
        op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
        if ( op->o_bd == NULL ) {
+               op->o_bd = bd;
                rs->sr_ref = referral_rewrite( default_referral,
                        NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                if ( !rs->sr_ref ) {
@@ -310,19 +311,15 @@ fe_op_modify( Operation *op, SlapReply *rs )
 
                if ( rs->sr_ref != NULL ) {
                        rs->sr_err = LDAP_REFERRAL;
-                       op->o_bd = frontendDB;
                        send_ldap_result( op, rs );
-                       op->o_bd = NULL;
 
                        if ( rs->sr_ref != default_referral ) {
                                ber_bvarray_free( rs->sr_ref );
                        }
 
                } else {
-                       op->o_bd = frontendDB;
                        send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                "no global superior knowledge" );
-                       op->o_bd = NULL;
                }
                goto cleanup;
        }
@@ -431,6 +428,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
        }
 
 cleanup:;
+       op->o_bd = bd;
        return rs->sr_err;
 }
 
@@ -835,11 +833,11 @@ void slap_mods_opattrs(
                        csn = op->o_csn;
                }
                ptr = ber_bvchr( &csn, '#' );
-               if ( ptr && ptr < &csn.bv_val[csn.bv_len] ) {
+               if ( ptr ) {
                        timestamp.bv_len = ptr - csn.bv_val;
-                       if ( timestamp.bv_len >= sizeof( timebuf ))
+                       if ( timestamp.bv_len >= sizeof( timebuf ))     /* ?!? */
                                timestamp.bv_len = sizeof( timebuf ) - 1;
-                       strncpy( timebuf, csn.bv_val, timestamp.bv_len );
+                       AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len );
                        timebuf[timestamp.bv_len] = '\0';
                } else {
                        time_t now = slap_get_time();