Skip to content
Snippets Groups Projects
Commit 4f77f04a authored by Luke Howard's avatar Luke Howard
Browse files

Don't use thread local malloc for search filter if SLAPI is enabled;

breaks API compat
parent 0e46e4a7
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ do_search(
int manageDSAit;
#ifdef LDAP_SLAPI
char **attrs = NULL;
Operation ch_op;
#endif
#ifdef NEW_LOGGING
......@@ -135,7 +136,20 @@ do_search(
#endif
/* filter - returns a "normalized" version */
#ifdef LDAP_SLAPI
/*
* SLAPI computed search rewriter plugins can reset the search
* filter, and because they have no way to specify the use of
* the thread-local malloc replacement, we must always use
* ch_malloc() to allocate the filter when SLAPI is enabled.
*/
ch_op = *op; /* struct copy */
ch_op.o_tmpmemctx = NULL;
ch_op.o_tmpmfuncs = &ch_mfuncs;
rs->sr_err = get_filter( &ch_op, op->o_ber, &op->ors_filter, &rs->sr_text );
#else
rs->sr_err = get_filter( op, op->o_ber, &op->ors_filter, &rs->sr_text );
#endif /* LDAP_SLAPI */
if( rs->sr_err != LDAP_SUCCESS ) {
if( rs->sr_err == SLAPD_DISCONNECT ) {
rs->sr_err = LDAP_PROTOCOL_ERROR;
......@@ -396,7 +410,11 @@ return_results:;
if( op->o_req_ndn.bv_val != NULL) sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
if( op->ors_filterstr.bv_val != NULL) op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
#ifdef LDAP_SLAPI
if( op->ors_filter != NULL) filter_free( op->ors_filter );
#else
if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter );
#endif
if( op->ors_attrs != NULL ) op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
#ifdef LDAP_SLAPI
if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx );
......@@ -472,36 +490,21 @@ static int doPreSearchPluginFNs( Operation *op )
static int doSearchRewriteFNs( Operation *op )
{
if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
Filter *f;
/*
* The plugin can set the SLAPI_SEARCH_FILTER.
* SLAPI_SEARCH_STRFILER is not normative.
*/
slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&f );
if ( f != op->ors_filter ) {
/* Plugin modified filter. Is pointer comparison safe? */
/*
* This is inefficient but it is not possible to expose the
* new memory allocation API through SLAPI.
*
* Further, the plugin should be responsible for freeing
* the original filter, but there is no way to communicate
* the memory context through the SLAPI filter free API.
*/
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
filter2bv_x( op, f, &op->ors_filterstr );
filter_free_x( op, op->ors_filter );
op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ARGS,
"doSearchRewriteFNs: after compute_rewrite_search filter: %s\n",
op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
LDAP_LOG( OPERATION, ARGS,
"doSearchRewriteFNs: after compute_rewrite_search filter: %s\n",
op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
#else
Debug( LDAP_DEBUG_ARGS, " after compute_rewrite_search filter: %s\n",
op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
Debug( LDAP_DEBUG_ARGS, " after compute_rewrite_search filter: %s\n",
op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
#endif
}
}
return LDAP_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment