mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
fix up error handling, including disallowing sync+pagedResults combinations.
This commit is contained in:
parent
75e415472d
commit
13c70ed410
@ -348,8 +348,7 @@ find_ctrl( const char *oid )
|
||||
|
||||
void slap_free_ctrls(
|
||||
Operation *op,
|
||||
LDAPControl **ctrls
|
||||
)
|
||||
LDAPControl **ctrls )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -582,8 +581,8 @@ int get_ctrls(
|
||||
if( sc->sc_extendedops != NULL ) {
|
||||
int i;
|
||||
for( i=0; sc->sc_extendedops[i] != NULL; i++ ) {
|
||||
if( strcmp( op->ore_reqoid.bv_val, sc->sc_extendedops[i] )
|
||||
== 0 )
|
||||
if( strcmp( op->ore_reqoid.bv_val,
|
||||
sc->sc_extendedops[i] ) == 0 )
|
||||
{
|
||||
tagmask=0L;
|
||||
break;
|
||||
@ -607,7 +606,7 @@ int get_ctrls(
|
||||
}
|
||||
|
||||
rs->sr_err = sc->sc_parse( op, rs, c );
|
||||
|
||||
assert( rs->sr_err != LDAP_UNAVAILABLE_CRITICAL_EXTENSION );
|
||||
if( rs->sr_err != LDAP_SUCCESS ) goto return_results;
|
||||
|
||||
if ( sc->sc_mask & SLAP_CTRL_FRONTEND ) {
|
||||
@ -666,7 +665,7 @@ static int parseModifyIncrement (
|
||||
LDAPControl *ctrl )
|
||||
{
|
||||
#if 0
|
||||
if ( op->o_parseModifyIncrement != SLAP_NO_CONTROL ) {
|
||||
if ( op->o_modifyIncrement != SLAP_NO_CONTROL ) {
|
||||
rs->sr_text = "modifyIncrement control specified multiple times";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
@ -678,7 +677,7 @@ static int parseModifyIncrement (
|
||||
}
|
||||
|
||||
#if 0
|
||||
op->o_parseModifyIncrement = ctrl->ldctl_iscritical
|
||||
op->o_modifyIncrement = ctrl->ldctl_iscritical
|
||||
? SLAP_CRITICAL_CONTROL
|
||||
: SLAP_NONCRITICAL_CONTROL;
|
||||
#endif
|
||||
@ -850,6 +849,11 @@ static int parsePagedResults (
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if ( op->o_sync != SLAP_NO_CONTROL ) {
|
||||
rs->sr_text = "paged results control specified with sync control";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if ( ctrl->ldctl_value.bv_len == 0 ) {
|
||||
rs->sr_text = "paged results control value is empty (or absent)";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
@ -1284,7 +1288,8 @@ static int parseSearchOptions (
|
||||
|
||||
if ( search_flags & LDAP_SEARCH_FLAG_DOMAIN_SCOPE ) {
|
||||
if ( op->o_domain_scope != SLAP_NO_CONTROL ) {
|
||||
rs->sr_text = "searchOptions control specified multiple times or with domainScope control";
|
||||
rs->sr_text = "searchOptions control specified multiple times "
|
||||
"or with domainScope control";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -1295,8 +1300,8 @@ static int parseSearchOptions (
|
||||
|
||||
if ( search_flags & ~(LDAP_SEARCH_FLAG_DOMAIN_SCOPE) ) {
|
||||
/* Other search flags not recognised so far */
|
||||
rs->sr_text = "searchOptions contained invalid flag";
|
||||
return LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
|
||||
rs->sr_text = "searchOptions contained unrecongized flag";
|
||||
return LDAP_UNWILLING_TO_PERFORM;
|
||||
}
|
||||
|
||||
return LDAP_SUCCESS;
|
||||
@ -1315,12 +1320,18 @@ static int parseLDAPsync (
|
||||
struct slap_session_entry *se;
|
||||
|
||||
if ( op->o_sync != SLAP_NO_CONTROL ) {
|
||||
rs->sr_text = "LDAP Sync control specified multiple times";
|
||||
rs->sr_text = "Sync control specified multiple times";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if ( op->o_pagedresults != SLAP_NO_CONTROL ) {
|
||||
rs->sr_text = "Sync control specified with pagedResults control";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if ( ctrl->ldctl_value.bv_len == 0 ) {
|
||||
rs->sr_text = "LDAP Sync control value is empty (or absent)";
|
||||
rs->sr_text = "Sync control value is empty (or absent)";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -1343,7 +1354,7 @@ static int parseLDAPsync (
|
||||
}
|
||||
|
||||
if ( (tag = ber_scanf( ber, "{i" /*}*/, &mode )) == LBER_ERROR ) {
|
||||
rs->sr_text = "LDAP Sync control : mode decoding error";
|
||||
rs->sr_text = "Sync control : mode decoding error";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -1355,7 +1366,7 @@ static int parseLDAPsync (
|
||||
mode = SLAP_SYNC_REFRESH_AND_PERSIST;
|
||||
break;
|
||||
default:
|
||||
rs->sr_text = "LDAP Sync control : unknown update mode";
|
||||
rs->sr_text = "Sync control : unknown update mode";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -1364,7 +1375,7 @@ static int parseLDAPsync (
|
||||
if ( tag == LDAP_TAG_SYNC_COOKIE ) {
|
||||
struct berval tmp_bv;
|
||||
if (( ber_scanf( ber, /*{*/ "o", &tmp_bv )) == LBER_ERROR ) {
|
||||
rs->sr_text = "LDAP Sync control : cookie decoding error";
|
||||
rs->sr_text = "Sync control : cookie decoding error";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
ber_bvarray_add( &op->o_sync_state.octet_str, &tmp_bv );
|
||||
@ -1372,12 +1383,12 @@ static int parseLDAPsync (
|
||||
}
|
||||
if ( tag == LDAP_TAG_RELOAD_HINT ) {
|
||||
if (( ber_scanf( ber, /*{*/ "b", &op->o_sync_rhint )) == LBER_ERROR ) {
|
||||
rs->sr_text = "LDAP Sync control : rhint decoding error";
|
||||
rs->sr_text = "Sync control : rhint decoding error";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
}
|
||||
if (( ber_scanf( ber, /*{*/ "}")) == LBER_ERROR ) {
|
||||
rs->sr_text = "LDAP Sync control : decoding error";
|
||||
rs->sr_text = "Sync control : decoding error";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user