[SSSD] [PATCH] Free controls in sdap_rebind_proc

Jakub Hrozek jhrozek at redhat.com
Tue Apr 10 14:03:17 UTC 2012


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.
-------------- next part --------------
>From 87471fd43b847c44661a190cb2a580b163613a53 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at 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, 7 insertions(+), 3 deletions(-)

diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index 02963f327dc44463c8458bef6806261748740b10..b30f715216b9c5caa429c0369a8470f6ee78247a 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -1743,7 +1743,9 @@ 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"));
+                if (ctrls[0]) ldap_control_free(ctrls[0]);
+                DEBUG(SSSDBG_CRIT_FAILURE,
+                     ("sdap_auth_get_authtok failed.\n"));
                 ret = LDAP_LOCAL_ERROR;
                 goto done;
             }
@@ -1751,9 +1753,11 @@ 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 (ctrls[0]) ldap_control_free(ctrls[0]);
         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);
-- 
1.7.7.6



More information about the sssd-devel mailing list