]> git.sur5r.net Git - openldap/commitdiff
ITS#6778
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 23:33:50 +0000 (23:33 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 23:33:50 +0000 (23:33 +0000)
CHANGES
clients/tools/common.c

diff --git a/CHANGES b/CHANGES
index f921e93e06267000c912ed5fb4e261dcf5839482..c65013ff3535468b4b564ca199390bcb0f61e798 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,7 @@ OpenLDAP 2.4.24 Engineering
        Added contrib/kinit for kerberos tickets
        Added contrib/noopsrch for entry counting (ITS#6598)
        Fixed client tools control logging (ITS#6775)
+       Fixed client tools one time leak (ITS#6778)
        Fixed liblber to not close invalid sockets (ITS#6585)
        Fixed liblber unmatched brace handling (ITS#6764)
        Fixed liblber error setting (ITS#6732)
index 5eef356604ac4cd51653f8093afc58ae63717119..499f568ad77c7e795378b52e5424aad6ba25f5b5 100644 (file)
@@ -253,20 +253,47 @@ tool_destroy( void )
 
        if ( pr_cookie.bv_val != NULL ) {
                ber_memfree( pr_cookie.bv_val );
-               pr_cookie.bv_val = NULL;
-               pr_cookie.bv_len = 0;
+               BER_BVZERO( &pr_cookie );
        }
 
        if ( binddn != NULL ) {
                ber_memfree( binddn );
+               binddn = NULL;
        }
 
        if ( passwd.bv_val != NULL ) {
                ber_memfree( passwd.bv_val );
+               BER_BVZERO( &passwd );
        }
 
        if ( infile != NULL ) {
                ber_memfree( infile );
+               infile = NULL;
+       }
+
+       if ( assertion ) {
+               ber_memfree( assertion );
+               assertion = NULL;
+       }
+
+       if ( authzid ) {
+               ber_memfree( authzid );
+               authzid = NULL;
+       }
+
+       if ( proxydn ) {
+               ber_memfree( proxydn );
+               proxydn = NULL;
+       }
+
+       if ( preread_attrs ) {
+               ber_memfree( preread_attrs );
+               preread_attrs = NULL;
+       }
+
+       if ( postread_attrs ) {
+               ber_memfree( postread_attrs );
+               postread_attrs = NULL;
        }
 }
 
@@ -427,7 +454,7 @@ tool_args( int argc, char **argv )
                                assertctl = 1 + crit;
 
                                assert( assertion == NULL );
-                               assertion = cvalue;
+                               assertion = ber_strdup( cvalue );
 
                        } else if ( strcasecmp( control, "authzid" ) == 0 ) {
                                if( authzid != NULL ) {
@@ -450,7 +477,7 @@ tool_args( int argc, char **argv )
                                }
 
                                assert( authzid == NULL );
-                               authzid = cvalue;
+                               authzid = ber_strdup( cvalue );
 
 #ifdef LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ
                        } else if ( strcasecmp( control, "proxydn" ) == 0 ) {
@@ -472,7 +499,7 @@ tool_args( int argc, char **argv )
                                }
 
                                assert( proxydn == NULL );
-                               proxydn = cvalue;
+                               proxydn = ber_strdup( cvalue );
 #endif /* LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ */
 
                        } else if ( ( strcasecmp( control, "relax" ) == 0 ) ||
@@ -542,7 +569,7 @@ tool_args( int argc, char **argv )
                                }
 
                                preread = 1 + crit;
-                               preread_attrs = cvalue;
+                               preread_attrs = ber_strdup( cvalue );
 
                        } else if ( strcasecmp( control, "postread" ) == 0 ) {
                                if( postread ) {
@@ -551,7 +578,7 @@ tool_args( int argc, char **argv )
                                }
 
                                postread = 1 + crit;
-                               postread_attrs = cvalue;
+                               postread_attrs = ber_strdup( cvalue );
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
                        } else if ( strcasecmp( control, "chaining" ) == 0 ) {
@@ -642,6 +669,8 @@ tool_args( int argc, char **argv )
                                }
                                unknown_ctrls = tmpctrls;
                                ctrl.ldctl_oid = control;
+                               /* don't free it */
+                               control = NULL;
                                ctrl.ldctl_value.bv_val = NULL;
                                ctrl.ldctl_value.bv_len = 0;
                                ctrl.ldctl_iscritical = crit;
@@ -676,6 +705,10 @@ tool_args( int argc, char **argv )
                                        control );
                                usage();
                        }
+                       if ( control ) {
+                               ber_memfree( control );  
+                               control = NULL;
+                       }
                        break;
                case 'f':       /* read from file */
                        if( infile != NULL ) {