andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From f47fa41572268029d369d410c9bc6d0a831ba50a Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Thu, 8 May 2014 15:10:52 -0400
dc8c34
Subject: [PATCH 206/225] Ticket 47793 - Server crashes if uniqueMember is
dc8c34
 invalid syntax and memberOf                plugin is enabled.
dc8c34
dc8c34
Bug Description:  MemberOf assumes the DN value has the correct syntax, and
dc8c34
                  does not check the normalized value of that DN.  This
dc8c34
                  leads to dereferencing a NULL pointer and crash.
dc8c34
dc8c34
Fix Description:  Check the normalized value, and log a proper error.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47793
dc8c34
dc8c34
Reviewed by: nhosoi(Thanks!)
dc8c34
dc8c34
(cherry picked from commit 6816e1155b28fb65fe294099336c4acbbac8ad77)
dc8c34
(cherry picked from commit 5f14af25186ea3c68fafecf034a0563da6fca187)
dc8c34
---
dc8c34
 ldap/servers/plugins/memberof/memberof.c | 32 ++++++++++++++++++++++++--------
dc8c34
 1 file changed, 24 insertions(+), 8 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
dc8c34
index 49e0d7a..19fb8a5 100644
dc8c34
--- a/ldap/servers/plugins/memberof/memberof.c
dc8c34
+++ b/ldap/servers/plugins/memberof/memberof.c
dc8c34
@@ -1101,17 +1101,33 @@ memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
dc8c34
 	Slapi_Entry *e = 0; 
dc8c34
 	memberofstringll *ll = 0;
dc8c34
 	char *op_str = 0;
dc8c34
-	const char *op_to = slapi_sdn_get_ndn(op_to_sdn);
dc8c34
-	const char *op_this = slapi_sdn_get_ndn(op_this_sdn);
dc8c34
-	Slapi_Value *to_dn_val = slapi_value_new_string(op_to);
dc8c34
-	Slapi_Value *this_dn_val = slapi_value_new_string(op_this);
dc8c34
-
dc8c34
-	if(this_dn_val == NULL || to_dn_val == NULL){
dc8c34
+	const char *op_to;
dc8c34
+	const char *op_this;
dc8c34
+	Slapi_Value *to_dn_val = NULL;
dc8c34
+	Slapi_Value *this_dn_val = NULL;
dc8c34
+
dc8c34
+	op_to = slapi_sdn_get_ndn(op_to_sdn);
dc8c34
+	op_this = slapi_sdn_get_ndn(op_this_sdn);
dc8c34
+
dc8c34
+	/* Make sure we have valid DN's for the group(op_this) and the new member(op_to) */
dc8c34
+	if(op_to && op_this){
dc8c34
+		to_dn_val = slapi_value_new_string(op_to);
dc8c34
+		this_dn_val = slapi_value_new_string(op_this);
dc8c34
+	}
dc8c34
+	if(to_dn_val == NULL){
dc8c34
+		const char *udn = op_to_sdn ? slapi_sdn_get_udn(op_to_sdn) : "";
dc8c34
 		slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
dc8c34
-				"memberof_modop_one_replace_r: failed to get DN values (NULL)\n");
dc8c34
+			"memberof_modop_one_replace_r: failed to get DN value from "
dc8c34
+			"member value (%s)\n", udn);
dc8c34
+		goto bail;
dc8c34
+	}
dc8c34
+	if(this_dn_val == NULL){
dc8c34
+		const char *udn = op_this_sdn ? slapi_sdn_get_udn(op_this_sdn) : "";
dc8c34
+		slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
dc8c34
+			"memberof_modop_one_replace_r: failed to get DN value from "
dc8c34
+			"group (%s)\n", udn);
dc8c34
 		goto bail;
dc8c34
 	}
dc8c34
-
dc8c34
 	/* op_this and op_to are both case-normalized */
dc8c34
 	slapi_value_set_flags(this_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
dc8c34
 	slapi_value_set_flags(to_dn_val, SLAPI_ATTR_FLAG_NORMALIZED_CIS);
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34