]> git.sur5r.net Git - openldap/commitdiff
Don't leak SLAPI_RESULT_MATCHED
authorLuke Howard <lukeh@openldap.org>
Sat, 27 Sep 2003 03:59:40 +0000 (03:59 +0000)
committerLuke Howard <lukeh@openldap.org>
Sat, 27 Sep 2003 03:59:40 +0000 (03:59 +0000)
Call SLAPI_PLUGIN_PRE_RESULT_FN plugins

servers/slapd/result.c

index c5a6e777712db95896d4485fefafe1b7c1462879..08ddfda50f913cacdc873e450f6a35f8f99784e0 100644 (file)
@@ -372,9 +372,8 @@ send_ldap_response(
 
 #ifdef LDAP_SLAPI
        slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
-       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, ( rs->sr_matched != NULL ) ? (void *)ch_strdup( rs->sr_matched ) : NULL );
-       /* RESULT_TEXT is dup'd by pblock_set */
-       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, rs->sr_text );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
 #endif /* LDAP_SLAPI */
 
        ldap_pvt_thread_mutex_lock( &num_sent_mutex );
@@ -488,6 +487,20 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
                }
        }
 
+#ifdef LDAP_SLAPI
+       /*
+        * Call pre-result plugins. To avoid infinite recursion plugins
+        * should just set SLAPI_RESULT_CODE rather than sending a
+        * result if they wish to change the result.
+        */
+       slapi_x_pblock_set_operation( op->o_pb, op );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+
+       (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+#endif /* LDAP_SLAPI */
+
        if ( op->o_protocol < LDAP_VERSION3 ) {
                tmp = v2ref( rs->sr_ref, rs->sr_text );
                rs->sr_text = tmp;