From d2b024be4a7c3ecc8c543c6b9c4d7fb701f73c8a Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Thu, 30 Dec 2010 23:55:07 +0000 Subject: [PATCH] ITS#6758 Reset some SlapReply flags & data. Reset data more consistenlty. When resetting sr_entry after sending data, reset sr_flag as well. Reset rs_attrs and Extended Operation oid/data after setting and sending them. --- servers/slapd/back-bdb/search.c | 1 + servers/slapd/back-dnssrv/search.c | 2 +- servers/slapd/back-ldap/search.c | 3 ++- servers/slapd/back-ldif/ldif.c | 5 +++++ servers/slapd/back-ndb/search.cpp | 1 + servers/slapd/back-passwd/search.c | 7 +++++++ servers/slapd/back-perl/search.c | 5 +++-- servers/slapd/back-shell/result.c | 1 + servers/slapd/back-sock/result.c | 1 + servers/slapd/extended.c | 2 ++ servers/slapd/overlays/retcode.c | 2 ++ servers/slapd/overlays/translucent.c | 1 + 12 files changed, 27 insertions(+), 4 deletions(-) diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index d25bf0c077..9cc950f401 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -959,6 +959,7 @@ fetch_entry_retry: rs->sr_flags = REP_ENTRY_MUSTRELEASE; rs->sr_err = LDAP_SUCCESS; rs->sr_err = send_search_entry( op, rs ); + rs->sr_attrs = NULL; /* send_search_entry will usually free it. * an overlay might leave its own copy here; diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index 83a79cd417..b39069d827 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -219,6 +219,7 @@ dnssrv_back_search( send_search_entry( op, rs ); rs->sr_entry = NULL; rs->sr_attrs = NULL; + rs->sr_flags = 0; } entry_clean( &e ); @@ -237,4 +238,3 @@ done: if( urls != NULL ) ber_bvarray_free( urls ); return 0; } - diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 7bde44d763..5c0a1f96ce 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -371,6 +371,7 @@ retry: rs->sr_ctrls = NULL; } rs->sr_entry = NULL; + rs->sr_flags = 0; if ( !BER_BVISNULL( &ent.e_name ) ) { assert( ent.e_name.bv_val != bdn.bv_val ); op->o_tmpfree( ent.e_name.bv_val, op->o_tmpmemctx ); @@ -428,6 +429,7 @@ retry: BER_BVZERO( &rs->sr_ref[ cnt ] ); /* ignore return value by now */ + RS_ASSERT( !(rs->sr_flags & REP_ENTRY_MASK) ); rs->sr_entry = NULL; ( void )send_search_reference( op, rs ); @@ -1011,4 +1013,3 @@ cleanup: return rc; } - diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index 61f94504f4..11d2157b0a 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -660,9 +660,14 @@ ldif_send_entry( Operation *op, SlapReply *rs, Entry *e, int scope ) else if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) { rs->sr_entry = e; rs->sr_attrs = op->ors_attrs; + /* Could set REP_ENTRY_MUSTBEFREED too for efficiency, + * but refraining lets us test unFREEable MODIFIABLE + * entries. Like entries built on the stack. + */ rs->sr_flags = REP_ENTRY_MODIFIABLE; rc = send_search_entry( op, rs ); rs->sr_entry = NULL; + rs->sr_attrs = NULL; } } diff --git a/servers/slapd/back-ndb/search.cpp b/servers/slapd/back-ndb/search.cpp index 90e49b9823..a2573c50c6 100644 --- a/servers/slapd/back-ndb/search.cpp +++ b/servers/slapd/back-ndb/search.cpp @@ -483,6 +483,7 @@ static int ndb_oc_search( Operation *op, SlapReply *rs, Ndb *ndb, NdbTransaction rs->sr_flags = 0; rc = send_search_entry( op, rs ); rs->sr_entry = NULL; + rs->sr_attrs = NULL; } else { rc = 0; } diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index b5b3fcd581..47c6260b9c 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -123,6 +123,8 @@ passwd_back_search( rs->sr_attrs = op->ors_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); + rs->sr_flags = 0; + rs->sr_attrs = NULL; } entry_clean( &e ); @@ -173,6 +175,8 @@ passwd_back_search( rs->sr_attrs = op->ors_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); + rs->sr_flags = 0; + rs->sr_entry = NULL; } entry_clean( &e ); @@ -238,6 +242,9 @@ passwd_back_search( rs->sr_attrs = op->ors_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); + rs->sr_flags = 0; + rs->sr_entry = NULL; + rs->sr_attrs = NULL; } entry_clean( &e ); diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c index 6e852e02c7..ebdef67989 100644 --- a/servers/slapd/back-perl/search.c +++ b/servers/slapd/back-perl/search.c @@ -92,8 +92,10 @@ perl_back_search( rs->sr_flags = REP_ENTRY_MODIFIABLE; rs->sr_err = LDAP_SUCCESS; rs->sr_err = send_search_entry( op, rs ); + rs->sr_flags = 0; + rs->sr_attrs = NULL; + rs->sr_entry = NULL; if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) { - rs->sr_entry = NULL; goto done; } } @@ -124,4 +126,3 @@ done:; return 0; } - diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index 0862d7d449..bea0cf821d 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -103,6 +103,7 @@ read_and_send_results( rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); entry_free( rs->sr_entry ); + rs->sr_attrs = NULL; } bp = buf; diff --git a/servers/slapd/back-sock/result.c b/servers/slapd/back-sock/result.c index 3c8b69d207..a5195cac6a 100644 --- a/servers/slapd/back-sock/result.c +++ b/servers/slapd/back-sock/result.c @@ -100,6 +100,7 @@ sock_read_and_send_results( rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); entry_free( rs->sr_entry ); + rs->sr_attrs = NULL; } bp = buf; diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index a105ddfaa7..19feb54045 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -244,10 +244,12 @@ fe_extended( Operation *op, SlapReply *rs ) if ( rs->sr_rspoid != NULL ) { free( (char *)rs->sr_rspoid ); + rs->sr_rspoid = NULL; } if ( rs->sr_rspdata != NULL ) { ber_bvfree( rs->sr_rspdata ); + rs->sr_rspdata = NULL; } } /* end of OpenLDAP extended operation */ diff --git a/servers/slapd/overlays/retcode.c b/servers/slapd/overlays/retcode.c index e77fa6d2fd..ffa2e61570 100644 --- a/servers/slapd/overlays/retcode.c +++ b/servers/slapd/overlays/retcode.c @@ -165,7 +165,9 @@ retcode_send_onelevel( Operation *op, SlapReply *rs ) rs->sr_entry = &rdi->rdi_e; rs->sr_err = send_search_entry( op, rs ); + rs->sr_flags = 0; rs->sr_entry = NULL; + rs->sr_attrs = NULL; switch ( rs->sr_err ) { case LDAP_UNAVAILABLE: /* connection closed */ diff --git a/servers/slapd/overlays/translucent.c b/servers/slapd/overlays/translucent.c index d4d77b2551..2b07607898 100644 --- a/servers/slapd/overlays/translucent.c +++ b/servers/slapd/overlays/translucent.c @@ -1169,6 +1169,7 @@ static int translucent_search(Operation *op, SlapReply *rs) { av = tavl_next( av, TAVL_DIR_RIGHT ); } tavl_free( tc.list, NULL ); + rs->sr_flags = 0; rs->sr_entry = NULL; } send_ldap_result( op, rs ); -- 2.39.5