andykimpe / rpms / 389-ds-base

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