On Wed, Apr 18, 2012 at 11:28:36AM -0400, Stephen Gallagher wrote:
> On Tue, 2012-04-10 at 10:03 -0400, Jakub Hrozek wrote:
> > Yet another leak in the referral chasing code, this time quite small -
> > the leak control was 56 bytes per one invocation of the rebind proc.
> 
> Nack. I'd rather you moved the cleanup to the done: label. That way if
> we add any more code that might jump to cleanup, we won't reintroduce
> this leak.

OK, new patch is attached.
>From d746d70c86524f1b352296c2a31c21c145191940 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Tue, 10 Apr 2012 15:24:33 +0200
Subject: [PATCH] Free controls in sdap_rebind_proc

---
 src/providers/ldap/sdap_async_connection.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/providers/ldap/sdap_async_connection.c 
b/src/providers/ldap/sdap_async_connection.c
index 
1f50c19835fcc214bb9def1bf883228e32c4c533..fac078c33d66d80efe32f8bf1558aae0624c0d6c
 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -1747,7 +1747,8 @@ static int sdap_rebind_proc(LDAP *ldap, LDAP_CONST char 
*url, ber_tag_t request,
                                                         SDAP_DEFAULT_AUTHTOK),
                                         &password);
             if (ret != EOK) {
-                DEBUG(1, ("sdap_auth_get_authtok failed.\n"));
+                DEBUG(SSSDBG_CRIT_FAILURE,
+                     ("sdap_auth_get_authtok failed.\n"));
                 ret = LDAP_LOCAL_ERROR;
                 goto done;
             }
@@ -1756,8 +1757,9 @@ static int sdap_rebind_proc(LDAP *ldap, LDAP_CONST char 
*url, ber_tag_t request,
         ret = ldap_sasl_bind_s(ldap, user_dn, LDAP_SASL_SIMPLE, &password,
                                request_controls, NULL, NULL);
         if (ret != LDAP_SUCCESS) {
-            DEBUG(1, ("ldap_sasl_bind_s failed (%d)[%s]\n", ret,
-                      sss_ldap_err2string(ret)));
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  ("ldap_sasl_bind_s failed (%d)[%s]\n", ret,
+                  sss_ldap_err2string(ret)));
         }
     } else {
         sasl_bind_state = talloc_zero(tmp_ctx, struct sasl_bind_state);
@@ -1783,7 +1785,7 @@ static int sdap_rebind_proc(LDAP *ldap, LDAP_CONST char 
*url, ber_tag_t request,
              (ret == LDAP_SUCCESS ? "Successfully" : "Failed to"), url));
 
 done:
+    if (ctrls[0]) ldap_control_free(ctrls[0]);
     talloc_free(tmp_ctx);
-
     return ret;
 }
-- 
1.7.7.6

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to