andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 6 months ago
Clone

Blame SOURCES/0014-Ticket-48216-crash-in-ns-slapd-when-deleting-winSync.patch

a2f18f
From 4fe9f07d50f383e3765ba97294f8b641f7feefa3 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Thu, 9 Jul 2015 17:23:57 -0700
a2f18f
Subject: [PATCH 14/20] Ticket #48216 - crash in ns-slapd when deleting
a2f18f
 winSyncSubtreePair from sync agreement
a2f18f
a2f18f
Description: In free_subtree_pairs, the condition for stopping the
a2f18f
loop to clean up the AD and DS subtree dn was incomplete.
a2f18f
a2f18f
This patch checks the AD and DS subtree dn and if any of the pair
a2f18f
is NULL, it stops the clean up.  Related to the issue, more checks
a2f18f
for the validation of the winSyncSubtreePair is added so that any
a2f18f
single valued cases are ignored with an error log.
a2f18f
[single valued case examples]
a2f18f
  winSyncSubtreePair: ou=People,dc=anytree
a2f18f
  winSyncSubtreePair: ou=People,dc=anytree:
a2f18f
  winSyncSubtreePair: :ou=People,dc=anytree
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48216
a2f18f
a2f18f
Reviewed by rmeggins@redht.com (Thank you, Rich!!)
a2f18f
a2f18f
(cherry picked from commit 6dce81e77a47dc23e0b825952c97112039f45201)
a2f18f
(cherry picked from commit 6d177bf359c022f1e46d575c6fe3ad3d97f1cfeb)
a2f18f
---
a2f18f
 ldap/servers/plugins/replication/windows_private.c | 14 ++++++++++++--
a2f18f
 1 file changed, 12 insertions(+), 2 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
a2f18f
index 36015c2..f5cb44e 100644
a2f18f
--- a/ldap/servers/plugins/replication/windows_private.c
a2f18f
+++ b/ldap/servers/plugins/replication/windows_private.c
a2f18f
@@ -885,7 +885,7 @@ windows_private_get_subtreepairs(const Repl_Agmt *ra)
a2f18f
 	return dp->subtree_pairs;
a2f18f
 }
a2f18f
 
a2f18f
-/* parray is NOT passed in */
a2f18f
+/* parray is NOT passed in; caller frees it. */
a2f18f
 void
a2f18f
 windows_private_set_subtreepairs(const Repl_Agmt *ra, char **parray)
a2f18f
 {
a2f18f
@@ -930,6 +930,12 @@ create_subtree_pairs(char **pairs)
a2f18f
 	for (ptr = pairs; ptr && *ptr; ptr++) {
a2f18f
 		p0 = ldap_utf8strtok_r(*ptr, ":", &saveptr);
a2f18f
 		p1 = ldap_utf8strtok_r(NULL, ":", &saveptr);
a2f18f
+		if ((NULL == p0) || (NULL == p1)) {
a2f18f
+			LDAPDebug1Arg(LDAP_DEBUG_ANY, 
a2f18f
+			              "create_subtree_pairs: "
a2f18f
+			              "Ignoring invalid subtree pairs \"%s\".\n", *ptr);
a2f18f
+			continue;
a2f18f
+		}
a2f18f
 		spp->DSsubtree = slapi_sdn_new_dn_byval(p0);
a2f18f
 		if (NULL == spp->DSsubtree) {
a2f18f
 			LDAPDebug1Arg(LDAP_DEBUG_ANY, 
a2f18f
@@ -960,7 +966,11 @@ free_subtree_pairs(subtreePair **pairs)
a2f18f
 	if (NULL == pairs) {
a2f18f
 		return;
a2f18f
 	}
a2f18f
-	for (p = *pairs; p; p++) {
a2f18f
+	/*
a2f18f
+	 * If exists, the subtree pair is both non-NULL or NULL.
a2f18f
+	 * Both NULL is the condition to stop the loop.
a2f18f
+	 */
a2f18f
+	for (p = *pairs; p && p->ADsubtree && p->DSsubtree; p++) {
a2f18f
 		slapi_sdn_free(&(p->ADsubtree));
a2f18f
 		slapi_sdn_free(&(p->DSsubtree));
a2f18f
 	}
a2f18f
-- 
a2f18f
1.9.3
a2f18f