Blame SOURCES/0064-Ticket-48284-free-entry-when-internal-add-fails.patch

a2f18f
From d1598673937a83127249e6c26de6af3a18a5f51c Mon Sep 17 00:00:00 2001
a2f18f
From: Mark Reynolds <mreynolds@redhat.com>
a2f18f
Date: Tue, 22 Sep 2015 13:41:06 -0400
a2f18f
Subject: [PATCH 64/65] Ticket 48284 - free entry when internal add fails
a2f18f
a2f18f
Bug Description:  The entry passed to an internal add operaton is expected
a2f18f
                  to be consumed, but it is not freed during an internal
a2f18f
                  add when setting slapi_add_internal_pb() returns an error.
a2f18f
a2f18f
Fix Description:  Free the entry in slapi_add_internal_pb() when the operation
a2f18f
                  is not allowed.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48284
a2f18f
a2f18f
Reviewed by: nhosoi(Thanks!)
a2f18f
a2f18f
(cherry picked from commit 622be8bfbc942fe100b8880df72db26e99e1c954)
a2f18f
(cherry picked from commit 99dbfb7601daea80f80d1ea9d29766d76555e01a)
a2f18f
---
a2f18f
 ldap/servers/slapd/add.c | 10 ++++++++--
a2f18f
 1 file changed, 8 insertions(+), 2 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
a2f18f
index 5eb2042..31012a2 100644
a2f18f
--- a/ldap/servers/slapd/add.c
a2f18f
+++ b/ldap/servers/slapd/add.c
a2f18f
@@ -316,6 +316,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
a2f18f
 
a2f18f
 	if (!allow_operation (pb))
a2f18f
 	{
a2f18f
+		/* free the entry as it's expected to be consumed */
a2f18f
+		Slapi_Entry *e;
a2f18f
+		slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
a2f18f
+		slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
a2f18f
+		slapi_entry_free(e);
a2f18f
+
a2f18f
 		slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
a2f18f
 						 "This plugin is not configured to access operation target data", 0, NULL );
a2f18f
 		return 0;
a2f18f
@@ -727,8 +733,8 @@ static void op_shared_add (Slapi_PBlock *pb)
a2f18f
 				slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse;;
a2f18f
 				do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
a2f18f
 				/* 
a2f18f
-				 * If be_add succeeded, then e is consumed except the resurect case.
a2f18f
-				 * If it is resurect, the corresponding tombstone entry is resurected
a2f18f
+				 * If be_add succeeded, then e is consumed except the resurrect case.
a2f18f
+				 * If it is resurrect, the corresponding tombstone entry is resurrected
a2f18f
 				 * and put into the cache.
a2f18f
 				 * Otherwise, we set e to NULL to prevent freeing it ourselves.
a2f18f
 				 */
a2f18f
-- 
a2f18f
1.9.3
a2f18f