mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-18 15:20:35 +08:00
Fix ldap_init/initialize error checking
This commit is contained in:
parent
e717717a8b
commit
e366aefffc
@ -501,20 +501,25 @@ main( int argc, char **argv )
|
||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||
ldapport );
|
||||
}
|
||||
|
||||
ld = ldap_init( ldaphost, ldapport );
|
||||
if( ld == NULL ) {
|
||||
perror("ldapsearch: ldap_init");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||
}
|
||||
(void) ldap_initialize( &ld, ldapuri );
|
||||
}
|
||||
|
||||
if( ld == NULL ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
rc = ldap_initialize( &ld, ldapuri );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -568,20 +568,25 @@ main( int argc, char **argv )
|
||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||
ldapport );
|
||||
}
|
||||
|
||||
ld = ldap_init( ldaphost, ldapport );
|
||||
if( ld == NULL ) {
|
||||
perror("ldapsearch: ldap_init");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||
}
|
||||
(void) ldap_initialize( &ld, ldapuri );
|
||||
}
|
||||
|
||||
if( ld == NULL ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
rc = ldap_initialize( &ld, ldapuri );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* referrals */
|
||||
|
@ -544,20 +544,25 @@ main(int argc, char **argv)
|
||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||
ldapport );
|
||||
}
|
||||
|
||||
ld = ldap_init( ldaphost, ldapport );
|
||||
if( ld == NULL ) {
|
||||
perror("ldapsearch: ldap_init");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||
}
|
||||
(void) ldap_initialize( &ld, ldapuri );
|
||||
}
|
||||
|
||||
if( ld == NULL ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
rc = ldap_initialize( &ld, ldapuri );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* referrals */
|
||||
|
@ -558,20 +558,25 @@ main( int argc, char *argv[] )
|
||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||
ldapport );
|
||||
}
|
||||
|
||||
ld = ldap_init( ldaphost, ldapport );
|
||||
if( ld == NULL ) {
|
||||
perror("ldapsearch: ldap_init");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||
}
|
||||
(void) ldap_initialize( &ld, ldapuri );
|
||||
}
|
||||
|
||||
if( ld == NULL ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
rc = ldap_initialize( &ld, ldapuri );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* referrals */
|
||||
|
@ -663,27 +663,31 @@ main( int argc, char **argv )
|
||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||
#endif
|
||||
|
||||
|
||||
if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_init( %s, %d )\n",
|
||||
ldaphost != NULL ? ldaphost : "<DEFAULT>",
|
||||
ldapport );
|
||||
}
|
||||
|
||||
ld = ldap_init( ldaphost, ldapport );
|
||||
if( ld == NULL ) {
|
||||
perror("ldapsearch: ldap_init");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( verbose ) {
|
||||
fprintf( stderr, "ldap_initialize( %s )\n",
|
||||
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
|
||||
}
|
||||
(void) ldap_initialize( &ld, ldapuri );
|
||||
}
|
||||
|
||||
if( ld == NULL ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
rc = ldap_initialize( &ld, ldapuri );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
|
||||
rc, ldap_err2string(rc) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (deref != -1 &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user