summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2010-09-29 08:42:03 -0600
committerRich Megginson <rmeggins@redhat.com>2010-10-01 17:02:53 -0600
commit5f01b7913cc0c19bf8757351506f73adb1c9e58b (patch)
tree1f9e2707035e2d96cd935f253a642c23d626a960
parent32e2b04dd1d98d96d90fdfaa3841524b3003dcdb (diff)
downloadds-5f01b7913cc0c19bf8757351506f73adb1c9e58b.tar.gz
ds-5f01b7913cc0c19bf8757351506f73adb1c9e58b.tar.xz
ds-5f01b7913cc0c19bf8757351506f73adb1c9e58b.zip
fix pblock memory leak
acct_record_login() should use and destroy the pblock locally - it does not need to be passed in from the calling function
-rw-r--r--ldap/servers/plugins/acctpolicy/acct_plugin.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c b/ldap/servers/plugins/acctpolicy/acct_plugin.c
index 74dc3adf..14a05123 100644
--- a/ldap/servers/plugins/acctpolicy/acct_plugin.c
+++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c
@@ -92,7 +92,7 @@ done:
with the current time.
*/
static int
-acct_record_login( Slapi_PBlock *modpb, char *dn )
+acct_record_login( const char *dn )
{
int ldrc;
int rc = 0; /* Optimistic default */
@@ -103,6 +103,7 @@ acct_record_login( Slapi_PBlock *modpb, char *dn )
char *timestr = NULL;
acctPluginCfg *cfg;
void *plugin_id;
+ Slapi_PBlock *modpb = NULL;
cfg = get_config();
plugin_id = get_identity();
@@ -142,9 +143,8 @@ acct_record_login( Slapi_PBlock *modpb, char *dn )
}
done:
- if( timestr ) {
- slapi_ch_free_string( &timestr );
- }
+ slapi_pblock_destroy( modpb );
+ slapi_ch_free_string( &timestr );
return( rc );
}
@@ -222,17 +222,11 @@ done:
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL, NULL, 0, NULL );
}
- if( target_entry ) {
- slapi_entry_free( target_entry );
- }
+ slapi_entry_free( target_entry );
- if( sdn ) {
- slapi_sdn_free( &sdn );
- }
+ slapi_sdn_free( &sdn );
- if( policy ) {
- free_acctpolicy( &policy );
- }
+ free_acctpolicy( &policy );
slapi_log_error( SLAPI_LOG_PLUGIN, PRE_PLUGIN_NAME,
"<= acct_bind_preop\n" );
@@ -249,7 +243,6 @@ int
acct_bind_postop( Slapi_PBlock *pb )
{
char *dn = NULL;
- Slapi_PBlock *modpb = NULL;
int ldrc, tracklogin = 0;
int rc = 0; /* Optimistic default */
Slapi_DN *sdn = NULL;
@@ -300,7 +293,7 @@ acct_bind_postop( Slapi_PBlock *pb )
}
if( tracklogin ) {
- rc = acct_record_login( modpb, dn );
+ rc = acct_record_login( dn );
}
/* ...Any additional account policy postops go here... */
@@ -310,21 +303,11 @@ done:
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL, NULL, 0, NULL );
}
- if( modpb ) {
- slapi_pblock_destroy( modpb );
- }
+ slapi_entry_free( target_entry );
- if( target_entry ) {
- slapi_entry_free( target_entry );
- }
+ slapi_sdn_free( &sdn );
- if( sdn ) {
- slapi_sdn_free( &sdn );
- }
-
- if( dn ) {
- slapi_ch_free_string( &dn );
- }
+ slapi_ch_free_string( &dn );
slapi_log_error( SLAPI_LOG_PLUGIN, POST_PLUGIN_NAME,
"<= acct_bind_postop\n" );