From: Howard Chu Date: Thu, 2 Feb 2023 15:08:34 +0000 (+0000) Subject: \ITS#9996 librewrite plug potential leak in ldapmap map_ldap_apply() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9507a834c0584f942b735fcc78dcc3bd6ff38ed;p=thirdparty%2Fopenldap.git \ITS#9996 librewrite plug potential leak in ldapmap map_ldap_apply() --- diff --git a/libraries/librewrite/ldapmap.c b/libraries/librewrite/ldapmap.c index 7d0252bb32..d9437d1a4b 100644 --- a/libraries/librewrite/ldapmap.c +++ b/libraries/librewrite/ldapmap.c @@ -360,11 +360,13 @@ do_bind:; data->lm_attrs, 0, NULL, NULL, NULL, 1, &res ); if ( rc == LDAP_SERVER_DOWN && first_try ) { first_try = 0; - if ( ldap_initialize( &ld, data->lm_url ) != LDAP_SUCCESS ) { + if ( ldap_initialize( &ld, data->lm_url ) != LDAP_SUCCESS ) { rc = REWRITE_ERR; goto rc_return; } set_version = 1; + ldap_msgfree( res ); + res = NULL; goto do_bind; } else if ( rc != LDAP_SUCCESS ) { @@ -373,7 +375,6 @@ do_bind:; } if ( ldap_count_entries( ld, res ) != 1 ) { - ldap_msgfree( res ); rc = REWRITE_ERR; goto rc_return; } @@ -408,14 +409,14 @@ do_bind:; } } - ldap_msgfree( res ); - if ( val->bv_val == NULL ) { rc = REWRITE_ERR; goto rc_return; } rc_return:; + ldap_msgfree( res ); + if ( data->lm_when == MAP_LDAP_EVERYTIME ) { if ( ld != NULL ) { ldap_unbind_ext( ld, NULL, NULL );