浏览代码

Ticket #48109 - substring index with nssubstrbegin: 1 is not being used with filters like (attr=x*)

Description: In the commit ae69e4aa1dcec1c5f79af502b77d9e19a3d348ee,
when pblock is passed to slapi_attr_assertion2keys_sub_sv_pb from the
caller, the original slapdplugin is overwritten in the function.  In
the case, the original slapdplugin has to be backed up and restored.

https://fedorahosted.org/389/ticket/48109

Reviewed by [email protected] (Thank you, Rich!!)
Noriko Hosoi 10 年之前
父节点
当前提交
2eba67c469
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      ldap/servers/slapd/plugin_syntax.c

+ 10 - 1
ldap/servers/slapd/plugin_syntax.c

@@ -924,6 +924,7 @@ slapi_attr_assertion2keys_sub_sv_pb(
 	int			rc;
 	Slapi_PBlock		pipb;
 	struct slapdplugin	*pi = NULL;
+	struct slapdplugin	*origpi = NULL;
 	IFP a2k_fn = NULL;
 
 	LDAPDebug( LDAP_DEBUG_FILTER,
@@ -943,8 +944,11 @@ slapi_attr_assertion2keys_sub_sv_pb(
 	if (NULL == pb) {
 		pblock_init( &pipb );
 		pb = &pipb;
+	} else {
+		/* back up the original slapdplugin if any */
+		slapi_pblock_get(pb, SLAPI_PLUGIN, &origpi);
 	}
-	slapi_pblock_set( pb, SLAPI_PLUGIN, pi );
+	slapi_pblock_set(pb, SLAPI_PLUGIN, pi);
 
 	rc = -1;	/* means no assertion2keys function */
 	*ivals = NULL;
@@ -952,6 +956,11 @@ slapi_attr_assertion2keys_sub_sv_pb(
 		rc = (*a2k_fn)( pb, initial, any, final, ivals );
 	}
 
+	if (pb != &pipb) {
+		/* restore the original slapdplugin if pb is not local. */
+		slapi_pblock_set(pb, SLAPI_PLUGIN, origpi);
+	}
+
 	LDAPDebug( LDAP_DEBUG_FILTER,
 	    "<= slapi_attr_assertion2keys_sub_sv %d\n", rc, 0, 0 );
 	return( rc );