From e3144dc61bed56eba265883a8308ae61114a266f Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Sun, 4 May 2014 23:10:14 +0400 Subject: [PATCH] ldapauth memory leak fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Привет ! Исправил старую багу по утечки памяти в плагине .. теперь вообще не течет , глупая ошибка.. Вот так 3,5 года не попрограммируеш , срузу ошибку найдеш :) -- Kirill Lopuchov --- src/plugins/LdapPlugin/ldapauth.c | 14 +++++++++++--- src/plugins/LdapPlugin/ldapauth.txt | 10 ---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/plugins/LdapPlugin/ldapauth.c b/src/plugins/LdapPlugin/ldapauth.c index bc69f68..5b8231c 100644 --- a/src/plugins/LdapPlugin/ldapauth.c +++ b/src/plugins/LdapPlugin/ldapauth.c @@ -121,6 +121,9 @@ static int ldapfunc(struct clientparam *param) int rc = -1; char tmpbuf[1024]; + /* test proxy user auth ------------------------*/ + if(!param->username || !param->password) return 4; + if(strlen(param->password)==0) return 4; /* init ldap ---------------------- */ ld = ldap_init( ldap_serv, 389 ); @@ -131,9 +134,6 @@ static int ldapfunc(struct clientparam *param) return 7; } - /* test proxy user auth ------------------------*/ - if(!param->username || !param->password) return 4; - if(strlen(param->password)==0) return 4; /* this code for Active Directory LDAP catalog :( detail see documentation for plugin */ @@ -161,6 +161,14 @@ static int ldapfunc(struct clientparam *param) ldap_unbind_s(ld); ld = ldap_init( ldap_serv, 389 ); + + if ( ld == NULL ) + { + param->srv->logfunc(param,"Error ldap_init: No init lib ldap"); + /*ldap_perror( ld, "Error ldap_init" ); */ + return 7; + } + rc = ldap_bind_s( ld, ldap_user, ldap_pass, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) diff --git a/src/plugins/LdapPlugin/ldapauth.txt b/src/plugins/LdapPlugin/ldapauth.txt index 0c23a6e..89f04d5 100644 --- a/src/plugins/LdapPlugin/ldapauth.txt +++ b/src/plugins/LdapPlugin/ldapauth.txt @@ -27,11 +27,6 @@ http://lucas.bergmans.us/hacks/openldap/ unix (Freebsd) gcc. openldap-client. -!!!! !!!! - Win 2000 Serv 600 500 / . - 3proxy 40 . . - Open Ldap api - :) . 2. . @@ -328,11 +323,6 @@ http://lucas.bergmans.us/hacks/openldap/ unix (Freebsd) gcc. openldap-client. -!!!! !!!! - Win 2000 Serv 600 500 / . - 3proxy 40 . . - Open Ldap api - :) . 2. .