cleanup error check logic; don't deref be->controls when it's NULL

This commit is contained in:
Pierangelo Masarati 2002-08-29 10:43:39 +00:00
parent 519bf9e28a
commit e53d272b3f

View file

@ -254,34 +254,32 @@ int backend_startup(Backend *be)
if ( be->bd_info->bi_open ) { if ( be->bd_info->bi_open ) {
rc = be->bd_info->bi_open( be->bd_info ); rc = be->bd_info->bi_open( be->bd_info );
} if ( rc != 0 ) {
if(rc != 0) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT, "backend_startup: bi_open failed!\n", 0, 0, 0 ); LDAP_LOG( BACKEND, CRIT, "backend_startup: bi_open failed!\n", 0, 0, 0 );
#else #else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_open failed!\n", "backend_startup: bi_open failed!\n",
0, 0, 0 ); 0, 0, 0 );
#endif #endif
return rc; return rc;
}
} }
if ( be->bd_info->bi_db_open ) { if ( be->bd_info->bi_db_open ) {
rc = be->bd_info->bi_db_open( be ); rc = be->bd_info->bi_db_open( be );
} if ( rc != 0 ) {
if(rc != 0) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT, LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 ); "backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 );
#else #else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_open failed! (%d)\n", "backend_startup: bi_db_open failed! (%d)\n",
rc, 0, 0 ); rc, 0, 0 );
#endif #endif
return rc; return rc;
}
} }
return rc; return rc;
@ -297,18 +295,17 @@ int backend_startup(Backend *be)
if( backendInfo[i].bi_open ) { if( backendInfo[i].bi_open ) {
rc = backendInfo[i].bi_open( rc = backendInfo[i].bi_open(
&backendInfo[i] ); &backendInfo[i] );
} if ( rc != 0 ) {
if(rc != 0) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT, LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_open %d failed!\n", i, 0, 0 ); "backend_startup: bi_open %d failed!\n", i, 0, 0 );
#else #else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_open %d failed!\n", "backend_startup: bi_open %d failed!\n",
i, 0, 0 ); i, 0, 0 );
#endif #endif
return rc; return rc;
}
} }
} }
@ -320,18 +317,17 @@ int backend_startup(Backend *be)
if ( backendDB[i].bd_info->bi_db_open ) { if ( backendDB[i].bd_info->bi_db_open ) {
rc = backendDB[i].bd_info->bi_db_open( rc = backendDB[i].bd_info->bi_db_open(
&backendDB[i] ); &backendDB[i] );
} if ( rc != 0 ) {
if(rc != 0) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT, LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_db_open(%d) failed! (%d)\n", i, rc, 0 ); "backend_startup: bi_db_open(%d) failed! (%d)\n", i, rc, 0 );
#else #else
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_open(%d) failed! (%d)\n", "backend_startup: bi_db_open(%d) failed! (%d)\n",
i, rc, 0 ); i, rc, 0 );
#endif #endif
return rc; return rc;
}
} }
} }
@ -746,6 +742,11 @@ backend_check_controls(
return LDAP_SUCCESS; return LDAP_SUCCESS;
} }
if ( be->be_controls == NULL ) {
*text = "control unavailable in context";
return LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
}
for( ; *ctrls != NULL ; ctrls++ ) { for( ; *ctrls != NULL ; ctrls++ ) {
if( (*ctrls)->ldctl_iscritical && if( (*ctrls)->ldctl_iscritical &&
!ldap_charray_inlist( be->be_controls, (*ctrls)->ldctl_oid ) ) !ldap_charray_inlist( be->be_controls, (*ctrls)->ldctl_oid ) )