Commit 51d5db03 authored by Howard Chu's avatar Howard Chu
Browse files

ITS#4422, rearrange options to allow passing NULL args to TLS/Cyrus

parent 0f1023b6
......@@ -1186,7 +1186,7 @@ ldap_int_sasl_get_option( LDAP *ld, int option, void *arg )
int
ldap_int_sasl_set_option( LDAP *ld, int option, void *arg )
{
if ( ld == NULL )
if ( ld == NULL || arg == NULL )
return -1;
switch ( option ) {
......
......@@ -542,74 +542,12 @@ ldap_set_option(
return rc;
}
/* Only accessed from inside this function by ldap_set_rebind_proc() */
case LDAP_OPT_REBIND_PROC: {
lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_REBIND_PARAMS: {
lo->ldo_rebind_params = (void *)invalue;
} return LDAP_OPT_SUCCESS;
/* Only accessed from inside this function by ldap_set_nextref_proc() */
case LDAP_OPT_NEXTREF_PROC: {
lo->ldo_nextref_proc = (LDAP_NEXTREF_PROC *)invalue;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_NEXTREF_PARAMS: {
lo->ldo_nextref_params = (void *)invalue;
} return LDAP_OPT_SUCCESS;
}
if(invalue == NULL) {
/* no place to set from */
return LDAP_OPT_ERROR;
}
/* options which cannot withstand invalue == NULL */
switch(option) {
case LDAP_OPT_API_INFO:
case LDAP_OPT_DESC:
/* READ ONLY */
break;
case LDAP_OPT_DEREF:
lo->ldo_deref = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_SIZELIMIT:
lo->ldo_sizelimit = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_TIMELIMIT:
lo->ldo_timelimit = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_PROTOCOL_VERSION: {
int vers = * (const int *) invalue;
if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
/* not supported */
break;
}
lo->ldo_version = vers;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_ERROR_NUMBER: {
int err = * (const int *) invalue;
if(ld == NULL) {
/* need a struct ldap */
break;
}
ld->ld_errno = err;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_ERROR_STRING: {
const char *err = (const char *) invalue;
if(ld == NULL) {
/* need a struct ldap */
break;
return LDAP_OPT_ERROR;
}
if( ld->ld_error ) {
......@@ -627,7 +565,7 @@ ldap_set_option(
if (ld == NULL) {
/* need a struct ldap */
break;
return LDAP_OPT_ERROR;
}
if( ld->ld_matched ) {
......@@ -645,23 +583,52 @@ ldap_set_option(
if(ld == NULL) {
/* need a struct ldap */
break;
return LDAP_OPT_ERROR;
}
if( ld->ld_referrals ) {
LDAP_VFREE(ld->ld_referrals);
}
ld->ld_referrals = ldap_value_dup(referrals);
if ( referrals ) {
ld->ld_referrals = ldap_value_dup(referrals);
}
} return LDAP_OPT_SUCCESS;
/* Only accessed from inside this function by ldap_set_rebind_proc() */
case LDAP_OPT_REBIND_PROC: {
lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_REBIND_PARAMS: {
lo->ldo_rebind_params = (void *)invalue;
} return LDAP_OPT_SUCCESS;
/* Only accessed from inside this function by ldap_set_nextref_proc() */
case LDAP_OPT_NEXTREF_PROC: {
lo->ldo_nextref_proc = (LDAP_NEXTREF_PROC *)invalue;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_NEXTREF_PARAMS: {
lo->ldo_nextref_params = (void *)invalue;
} return LDAP_OPT_SUCCESS;
/* read-only options */
case LDAP_OPT_API_INFO:
case LDAP_OPT_DESC:
case LDAP_OPT_API_FEATURE_INFO:
/* read-only */
break;
return LDAP_OPT_ERROR;
/* options which cannot withstand invalue == NULL */
case LDAP_OPT_DEREF:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
case LDAP_OPT_PROTOCOL_VERSION:
case LDAP_OPT_ERROR_NUMBER:
case LDAP_OPT_DEBUG_LEVEL:
lo->ldo_debug = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
if(invalue == NULL) {
/* no place to set from */
return LDAP_OPT_ERROR;
}
break;
default:
#ifdef HAVE_TLS
......@@ -673,7 +640,47 @@ ldap_set_option(
return LDAP_OPT_SUCCESS;
#endif
/* bad param */
break;
return LDAP_OPT_ERROR;
}
/* options which cannot withstand invalue == NULL */
switch(option) {
case LDAP_OPT_DEREF:
lo->ldo_deref = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_SIZELIMIT:
lo->ldo_sizelimit = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_TIMELIMIT:
lo->ldo_timelimit = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_PROTOCOL_VERSION: {
int vers = * (const int *) invalue;
if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
/* not supported */
break;
}
lo->ldo_version = vers;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_ERROR_NUMBER: {
int err = * (const int *) invalue;
if(ld == NULL) {
/* need a struct ldap */
break;
}
ld->ld_errno = err;
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_DEBUG_LEVEL:
lo->ldo_debug = * (const int *) invalue;
return LDAP_OPT_SUCCESS;
}
return LDAP_OPT_ERROR;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment