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

5d2be4
From 3cf7734177c70c36062d4e667b91e15f22a2ea81 Mon Sep 17 00:00:00 2001
5d2be4
From: tbordaz <tbordaz@redhat.com>
5d2be4
Date: Wed, 25 Nov 2020 18:07:34 +0100
5d2be4
Subject: [PATCH 2/8] Issue 4297 - 2nd fix for on ADD replication URP issue
5d2be4
 internal searches with filter containing unescaped chars (#4439)
5d2be4
5d2be4
Bug description:
5d2be4
	Previous fix is buggy because slapi_filter_escape_filter_value returns
5d2be4
        a escaped filter component not an escaped assertion value.
5d2be4
5d2be4
Fix description:
5d2be4
	use the escaped filter component
5d2be4
5d2be4
relates: https://github.com/389ds/389-ds-base/issues/4297
5d2be4
5d2be4
Reviewed by: William Brown
5d2be4
5d2be4
Platforms tested: F31
5d2be4
---
5d2be4
 ldap/servers/plugins/replication/urp.c | 17 ++++++++---------
5d2be4
 1 file changed, 8 insertions(+), 9 deletions(-)
5d2be4
5d2be4
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
5d2be4
index 301e9fa00..96ad2759a 100644
5d2be4
--- a/ldap/servers/plugins/replication/urp.c
5d2be4
+++ b/ldap/servers/plugins/replication/urp.c
5d2be4
@@ -1411,12 +1411,12 @@ urp_add_check_tombstone (Slapi_PBlock *pb, char *sessionid, Slapi_Entry *entry,
5d2be4
     Slapi_Entry **entries = NULL;
5d2be4
     Slapi_PBlock *newpb;
5d2be4
     char *basedn = slapi_entry_get_ndn(entry);
5d2be4
-    char *escaped_basedn;
5d2be4
+    char *escaped_filter;
5d2be4
     const Slapi_DN *suffix = slapi_get_suffix_by_dn(slapi_entry_get_sdn (entry));
5d2be4
-    escaped_basedn = slapi_filter_escape_filter_value("nscpentrydn", basedn);
5d2be4
+    escaped_filter = slapi_filter_escape_filter_value("nscpentrydn", basedn);
5d2be4
 
5d2be4
-    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)(nscpentrydn=%s))", escaped_basedn);
5d2be4
-    slapi_ch_free((void **)&escaped_basedn);
5d2be4
+    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)%s)", escaped_filter);
5d2be4
+    slapi_ch_free((void **)&escaped_filter);
5d2be4
     newpb = slapi_pblock_new();
5d2be4
     slapi_search_internal_set_pb(newpb,
5d2be4
                                  slapi_sdn_get_dn(suffix), /* Base DN */
5d2be4
@@ -1605,15 +1605,14 @@ urp_find_tombstone_for_glue (Slapi_PBlock *pb, char *sessionid, const Slapi_Entr
5d2be4
     Slapi_Entry **entries = NULL;
5d2be4
     Slapi_PBlock *newpb;
5d2be4
     const char *basedn = slapi_sdn_get_dn(parentdn);
5d2be4
-    char *escaped_basedn;
5d2be4
-    escaped_basedn = slapi_filter_escape_filter_value("nscpentrydn", basedn);
5d2be4
-
5d2be4
+    char *escaped_filter;
5d2be4
+    escaped_filter = slapi_filter_escape_filter_value("nscpentrydn", (char *)basedn);
5d2be4
     char *conflict_csnstr = (char*)slapi_entry_attr_get_ref((Slapi_Entry *)entry, "conflictcsn");
5d2be4
     CSN *conflict_csn = csn_new_by_string(conflict_csnstr);
5d2be4
     CSN *tombstone_csn = NULL;
5d2be4
 
5d2be4
-    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)(nscpentrydn=%s))", escaped_basedn);
5d2be4
-    slapi_ch_free((void **)&escaped_basedn);
5d2be4
+    char *filter = slapi_filter_sprintf("(&(objectclass=nstombstone)%s)", escaped_filter);
5d2be4
+    slapi_ch_free((void **)&escaped_filter);
5d2be4
     newpb = slapi_pblock_new();
5d2be4
     char *parent_dn = slapi_dn_parent (basedn);
5d2be4
     slapi_search_internal_set_pb(newpb,
5d2be4
-- 
5d2be4
2.26.2
5d2be4