From 3c56e3905af3dff3b35d6cfa7c4f327fa9887f35 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Thu, 19 Mar 2015 15:29:39 -0700
Subject: [PATCH 308/308] Ticket #48135 - memory leak in new_passwdPolicy
(1.2.11 only)
Description: Backporting #47900 patch introduced a leak. The patch
has a dependency on #147, which was not backported to 1.2.11 branch.
This patch releases the pwdpolicy object in op_shared_add every time.
Also, moving new_passwdPolicy only where it is needed.
https://fedorahosted.org/389/ticket/48135
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit aa76f6b79db14c03c74b7c064f33a37bba991bf5)
---
ldap/servers/slapd/add.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index e03bc6c..f52f766 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -457,14 +457,13 @@ static void op_shared_add (Slapi_PBlock *pb)
int proxy_err = LDAP_SUCCESS;
char *errtext = NULL;
Slapi_DN *sdn = NULL;
- passwdPolicy *pwpolicy;
+ passwdPolicy *pwpolicy = NULL;
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_pblock_get (pb, SLAPI_ADD_ENTRY, &e);
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
slapi_pblock_get (pb, SLAPI_IS_LEGACY_REPLICATED_OPERATION, &legacy_op);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
- pwpolicy = new_passwdPolicy(pb, slapi_entry_get_dn(e));
/* target spec is used to decide which plugins are applicable for the operation */
operation_set_target_spec (operation, slapi_entry_get_sdn (e));
@@ -561,6 +560,7 @@ static void op_shared_add (Slapi_PBlock *pb)
}
/* check password syntax */
+ pwpolicy = new_passwdPolicy(pb, slapi_entry_get_dn(e));
if (!pw_is_pwp_admin(pb, pwpolicy) &&
check_pw_syntax(pb, slapi_entry_get_sdn_const(e), present_values, NULL, e, 0) != 0)
{
@@ -745,6 +745,7 @@ static void op_shared_add (Slapi_PBlock *pb)
done:
if (be)
slapi_be_Unlock(be);
+ delete_passwdPolicy(&pwpolicy);
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
slapi_entry_free(pse);
slapi_ch_free((void **)&operation->o_params.p.p_add.parentuniqueid);
--
1.9.3