]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9995 ldapdelete: plug potential search leak
authorHoward Chu <hyc@openldap.org>
Thu, 2 Feb 2023 15:03:51 +0000 (15:03 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 26 Apr 2023 16:42:43 +0000 (16:42 +0000)
clients/tools/ldapdelete.c

index 6024a332930dc4e41a9a3d9b37e5612d4a41a4e2..e572e4394eecd84ab399ea2c0464f9549eb4af9c 100644 (file)
@@ -386,7 +386,9 @@ more:;
                break;
        default:
                tool_perror( "ldap_search", srch_rc, NULL, NULL, NULL, NULL );
-               return( srch_rc );
+               rc = srch_rc;
+               srch_rc = 0;
+               goto leave;
        }
 
        entries = ldap_count_entries( ld, res );
@@ -402,15 +404,14 @@ more:;
                        if( dn == NULL ) {
                                ldap_get_option( ld, LDAP_OPT_RESULT_CODE, &rc );
                                tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
-                               ber_memfree( dn );
-                               return rc;
+                               goto leave;
                        }
 
                        rc = deletechildren( ld, dn, 0 );
                        if ( rc != LDAP_SUCCESS ) {
                                tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
                                ber_memfree( dn );
-                               return rc;
+                               goto leave;
                        }
 
                        if ( verbose ) {
@@ -421,7 +422,7 @@ more:;
                        if ( rc != LDAP_SUCCESS ) {
                                tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
                                ber_memfree( dn );
-                               return rc;
+                               goto leave;
 
                        }
                        
@@ -433,6 +434,7 @@ more:;
                }
        }
 
+leave:
        ldap_msgfree( res );
 
        if ( srch_rc == LDAP_SIZELIMIT_EXCEEDED ) {