mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-19 21:32:58 -05:00
Fix ldap_init/initialize error checking
This commit is contained in:
parent
e717717a8b
commit
e366aefffc
5 changed files with 55 additions and 31 deletions
|
|
@ -501,20 +501,25 @@ main( int argc, char **argv )
|
||||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||||
ldapport );
|
ldapport );
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = ldap_init( ldaphost, ldapport );
|
ld = ldap_init( ldaphost, ldapport );
|
||||||
|
if( ld == NULL ) {
|
||||||
|
perror("ldapsearch: ldap_init");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||||
}
|
}
|
||||||
(void) ldap_initialize( &ld, ldapuri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ld == NULL ) {
|
rc = ldap_initialize( &ld, ldapuri );
|
||||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
if( rc != LDAP_SUCCESS ) {
|
||||||
rc, ldap_err2string(rc) );
|
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||||
return EXIT_FAILURE;
|
rc, ldap_err2string(rc) );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -568,20 +568,25 @@ main( int argc, char **argv )
|
||||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||||
ldapport );
|
ldapport );
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = ldap_init( ldaphost, ldapport );
|
ld = ldap_init( ldaphost, ldapport );
|
||||||
|
if( ld == NULL ) {
|
||||||
|
perror("ldapsearch: ldap_init");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||||
}
|
}
|
||||||
(void) ldap_initialize( &ld, ldapuri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ld == NULL ) {
|
rc = ldap_initialize( &ld, ldapuri );
|
||||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
if( rc != LDAP_SUCCESS ) {
|
||||||
rc, ldap_err2string(rc) );
|
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||||
return EXIT_FAILURE;
|
rc, ldap_err2string(rc) );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* referrals */
|
/* referrals */
|
||||||
|
|
|
||||||
|
|
@ -544,20 +544,25 @@ main(int argc, char **argv)
|
||||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||||
ldapport );
|
ldapport );
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = ldap_init( ldaphost, ldapport );
|
ld = ldap_init( ldaphost, ldapport );
|
||||||
|
if( ld == NULL ) {
|
||||||
|
perror("ldapsearch: ldap_init");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||||
}
|
}
|
||||||
(void) ldap_initialize( &ld, ldapuri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ld == NULL ) {
|
rc = ldap_initialize( &ld, ldapuri );
|
||||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
if( rc != LDAP_SUCCESS ) {
|
||||||
rc, ldap_err2string(rc) );
|
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||||
return EXIT_FAILURE;
|
rc, ldap_err2string(rc) );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* referrals */
|
/* referrals */
|
||||||
|
|
|
||||||
|
|
@ -558,20 +558,25 @@ main( int argc, char *argv[] )
|
||||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||||
ldapport );
|
ldapport );
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = ldap_init( ldaphost, ldapport );
|
ld = ldap_init( ldaphost, ldapport );
|
||||||
|
if( ld == NULL ) {
|
||||||
|
perror("ldapsearch: ldap_init");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||||
}
|
}
|
||||||
(void) ldap_initialize( &ld, ldapuri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ld == NULL ) {
|
rc = ldap_initialize( &ld, ldapuri );
|
||||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
if( rc != LDAP_SUCCESS ) {
|
||||||
rc, ldap_err2string(rc) );
|
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||||
return EXIT_FAILURE;
|
rc, ldap_err2string(rc) );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* referrals */
|
/* referrals */
|
||||||
|
|
|
||||||
|
|
@ -663,27 +663,31 @@ main( int argc, char **argv )
|
||||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
|
if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_init( %s, %d )\n",
|
fprintf( stderr, "ldap_init( %s, %d )\n",
|
||||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||||
ldapport );
|
ldapport );
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = ldap_init( ldaphost, ldapport );
|
ld = ldap_init( ldaphost, ldapport );
|
||||||
|
if( ld == NULL ) {
|
||||||
|
perror("ldapsearch: ldap_init");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( verbose ) {
|
if ( verbose ) {
|
||||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||||
}
|
}
|
||||||
(void) ldap_initialize( &ld, ldapuri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ld == NULL ) {
|
rc = ldap_initialize( &ld, ldapuri );
|
||||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
if( rc != LDAP_SUCCESS ) {
|
||||||
rc, ldap_err2string(rc) );
|
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||||
return EXIT_FAILURE;
|
rc, ldap_err2string(rc) );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deref != -1 &&
|
if (deref != -1 &&
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue