andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 14a6dec3e2dc6a057d81582cf31ddcb07c6de97e Mon Sep 17 00:00:00 2001
dc8c34
From: Rich Megginson <rmeggins@redhat.com>
dc8c34
Date: Wed, 9 Apr 2014 13:19:08 -0600
dc8c34
Subject: [PATCH 197/225] Ticket #47773 - mem leak in do_bind when there is an
dc8c34
 error
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47773
dc8c34
Reviewed by: nhosoi (Thanks!)
dc8c34
Branch: 389-ds-base-1.2.11
dc8c34
Fix Description: Do not get the SLAPI_BIND_TARGET_SDN from the pblock and
dc8c34
free it in the clean up code if it was never set in the pblock - just free
dc8c34
the local variable sdn in this case.
dc8c34
Platforms tested: RHEL6 x86_64
dc8c34
Flag Day: no
dc8c34
Doc impact: no
dc8c34
(cherry picked from commit 2a57b521b86b24c0f0a8ddfbea4169c71ee4e896)
dc8c34
(cherry picked from commit c0606d45b91e87e4d0d90dec0812d20a0b23f545)
dc8c34
(cherry picked from commit 39eab765d9c6552c246bed13903807eca4c96887)
dc8c34
(cherry picked from commit 0911134c2c6d97243a7f6652a9a861bf7e28d91b)
dc8c34
(cherry picked from commit 7655ff76c90651d817bfbd70313228c9818ad591)
dc8c34
---
dc8c34
 ldap/servers/slapd/bind.c | 6 +++++-
dc8c34
 1 file changed, 5 insertions(+), 1 deletion(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
dc8c34
index 97b236e..92d7965 100644
dc8c34
--- a/ldap/servers/slapd/bind.c
dc8c34
+++ b/ldap/servers/slapd/bind.c
dc8c34
@@ -131,6 +131,7 @@ do_bind( Slapi_PBlock *pb )
dc8c34
     ber_tag_t ber_rc;
dc8c34
     int rc = 0;
dc8c34
     Slapi_DN *sdn = NULL;
dc8c34
+    int bind_sdn_in_pb = 0; /* is sdn set in the pb? */
dc8c34
     Slapi_Entry *referral;
dc8c34
     char errorbuf[BUFSIZ];
dc8c34
     char **supported, **pmech;
dc8c34
@@ -369,6 +370,7 @@ do_bind( Slapi_PBlock *pb )
dc8c34
     isroot = slapi_dn_isroot( slapi_sdn_get_ndn(sdn) );
dc8c34
     slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
dc8c34
     slapi_pblock_set( pb, SLAPI_BIND_TARGET_SDN, (void*)sdn );
dc8c34
+    bind_sdn_in_pb = 1; /* pb now owns sdn */
dc8c34
     slapi_pblock_set( pb, SLAPI_BIND_METHOD, &method );
dc8c34
     slapi_pblock_set( pb, SLAPI_BIND_SASLMECHANISM, saslmech );
dc8c34
     slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, &cred );
dc8c34
@@ -861,7 +863,9 @@ account_locked:
dc8c34
 free_and_return:;
dc8c34
     if (be)
dc8c34
         slapi_be_Unlock(be);
dc8c34
-    slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn;;
dc8c34
+    if (bind_sdn_in_pb) {
dc8c34
+	    slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn;;
dc8c34
+    }
dc8c34
     slapi_sdn_free(&sdn;;
dc8c34
     slapi_ch_free_string( &saslmech );
dc8c34
     slapi_ch_free( (void **)&cred.bv_val );
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34