Blame SOURCES/0013-Issue-4297-2nd-fix-for-on-ADD-replication-URP-issue-.patch

0c1fc4
From 19f44a6e703c16e807a51da2bfbd36b414041101 Mon Sep 17 00:00:00 2001
0c1fc4
From: Thierry Bordaz <tbordaz@redhat.com>
0c1fc4
Date: Wed, 25 Nov 2020 18:32:51 +0100
0c1fc4
Subject: [PATCH 1/2] Issue 4297: 2nd fix for on ADD replication URP issue
0c1fc4
 internal searches with filter containing unescaped chars
0c1fc4
0c1fc4
Bug description:
0c1fc4
	Previous fix is buggy because slapi_filter_escape_filter_value returns
0c1fc4
	a escaped filter component not an escaped assertion value.
0c1fc4
0c1fc4
Fix description:
0c1fc4
	use the escaped filter component
0c1fc4
0c1fc4
relates: #4297
0c1fc4
0c1fc4
Reviewed by: Mark Reynolds, William Brown (thanks !)
0c1fc4
0c1fc4
Platforms tested: F31
0c1fc4
---
0c1fc4
 ldap/servers/plugins/replication/urp.c | 15 ++++++++-------
0c1fc4
 1 file changed, 8 insertions(+), 7 deletions(-)
0c1fc4
0c1fc4
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
0c1fc4
index 2c2d83c6c..586c6936d 100644
0c1fc4
--- a/ldap/servers/plugins/replication/urp.c
0c1fc4
+++ b/ldap/servers/plugins/replication/urp.c
0c1fc4
@@ -1379,12 +1379,12 @@ urp_add_check_tombstone (Slapi_PBlock *pb, char *sessionid, Slapi_Entry *entry,
0c1fc4
     Slapi_Entry **entries = NULL;
0c1fc4
     Slapi_PBlock *newpb;
0c1fc4
     char *basedn = slapi_entry_get_ndn(entry);
0c1fc4
-    char *escaped_basedn;
0c1fc4
+    char *escaped_filter;
0c1fc4
     const Slapi_DN *suffix = slapi_get_suffix_by_dn(slapi_entry_get_sdn (entry));
0c1fc4
-    escaped_basedn = slapi_filter_escape_filter_value("nscpentrydn", basedn);
0c1fc4
+    escaped_filter = slapi_filter_escape_filter_value("nscpentrydn", basedn);
0c1fc4
 
0c1fc4
-    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)(nscpentrydn=%s))", escaped_basedn);
0c1fc4
-    slapi_ch_free((void **)&escaped_basedn);
0c1fc4
+    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)%s)", escaped_filter);
0c1fc4
+    slapi_ch_free((void **)&escaped_filter);
0c1fc4
     newpb = slapi_pblock_new();
0c1fc4
     slapi_search_internal_set_pb(newpb,
0c1fc4
                                  slapi_sdn_get_dn(suffix), /* Base DN */
0c1fc4
@@ -1577,12 +1577,13 @@ urp_find_tombstone_for_glue (Slapi_PBlock *pb, char *sessionid, const Slapi_Entr
0c1fc4
     Slapi_PBlock *newpb;
0c1fc4
     const char *basedn = slapi_sdn_get_dn(parentdn);
0c1fc4
     char *conflict_csnstr = slapi_entry_attr_get_charptr(entry, "conflictcsn");
0c1fc4
-    char *escaped_basedn = slapi_filter_escape_filter_value("nscpentrydn", basedn);
0c1fc4
+    char *escaped_filter;
0c1fc4
+    escaped_filter = slapi_filter_escape_filter_value("nscpentrydn", (char *)basedn);
0c1fc4
     CSN *conflict_csn = csn_new_by_string(conflict_csnstr);
0c1fc4
     slapi_ch_free_string(&conflict_csnstr);
0c1fc4
     CSN *tombstone_csn = NULL;
0c1fc4
-    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)(nscpentrydn=%s))", escaped_basedn);
0c1fc4
-    slapi_ch_free((void **)&escaped_basedn);
0c1fc4
+    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)%s)", escaped_filter);
0c1fc4
+    slapi_ch_free((void **)&escaped_filter);
0c1fc4
     newpb = slapi_pblock_new();
0c1fc4
     char *parent_dn = slapi_dn_parent (basedn);
0c1fc4
     slapi_search_internal_set_pb(newpb,
0c1fc4
-- 
0c1fc4
2.26.2
0c1fc4