Wrong argument (inst instead of conn) passed to the rebind callback in rlm_ldap
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 Oct 2013 11:01:28 +0000 (11:01 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 Oct 2013 11:02:21 +0000 (11:02 +0000)
src/modules/rlm_ldap/ldap.c

index b578e4e..83d3fef 100644 (file)
@@ -1057,7 +1057,16 @@ void *mod_conn_create(void *instance)
 
        ldap_instance_t *inst = instance;
        LDAP *handle = NULL;
-       ldap_handle_t *conn = NULL;
+       ldap_handle_t *conn;
+
+       /*
+        *      Allocate memory for the handle.
+        */
+       conn = talloc_zero(instance, ldap_handle_t);
+       conn->inst = inst;
+       conn->handle = handle;
+       conn->rebound = false;
+       conn->referred = false;
 
 #ifdef HAVE_LDAP_INITIALIZE
        if (inst->is_url) {
@@ -1104,7 +1113,7 @@ void *mod_conn_create(void *instance)
 
                        if (inst->rebind == true) {
 #if LDAP_SET_REBIND_PROC_ARGS == 3
-                               ldap_set_rebind_proc(handle, rlm_ldap_rebind, inst);
+                               ldap_set_rebind_proc(handle, rlm_ldap_rebind, conn);
 #endif
                        }
                } else {
@@ -1190,15 +1199,6 @@ void *mod_conn_create(void *instance)
        }
 #endif /* HAVE_LDAP_START_TLS */
 
-       /*
-        *      Allocate memory for the handle.
-        */
-       conn = talloc_zero(instance, ldap_handle_t);
-       conn->inst = inst;
-       conn->handle = handle;
-       conn->rebound = false;
-       conn->referred = false;
-
        status = rlm_ldap_bind(inst, NULL, &conn, inst->admin_dn, inst->password, false);
        if (status != LDAP_PROC_SUCCESS) {
                goto error;