Misc Clean.
if( (*ctrls)->ldctl_iscritical && !ldap_charray_inlist(
op->o_bd->be_controls, (*ctrls)->ldctl_oid ) )
{
+ /* FIXME: standards compliance issue
+ *
+ * Per RFC 2251 (and LDAPBIS discussions), if the control
+ * is recognized and appropriate for the operation (which
+ * we've already verified), then the server should make
+ * use of the control when performing the operation
+ * (without regard to criticality). This code is incorrect
+ * on two counts.
+ * 1) a service error (e.g., unwillingToPerform) should be
+ * returned where a particular backend cannot service the
+ * operation,
+ * 2) this error should be returned irregardless of the
+ * criticality of the control.
+ */
rs->sr_text = "control unavailable in context";
rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
break;
struct slap_control *sc;
int i;
- if ( controloid == NULL ) {
- return LDAP_PARAM_ERROR;
- }
+ if ( controloid == NULL ) return LDAP_PARAM_ERROR;
sc = (struct slap_control *)SLAP_MALLOC( sizeof( *sc ) );
- if ( sc == NULL ) {
- return LDAP_NO_MEMORY;
- }
+ if ( sc == NULL ) return LDAP_NO_MEMORY;
+
sc->sc_oid = ch_strdup( controloid );
sc->sc_mask = controlmask;
if ( controlexops != NULL ) {
if ( slap_known_controls == NULL ) {
slap_known_controls = (char **)SLAP_MALLOC( 2 * sizeof(char *) );
if ( slap_known_controls == NULL ) {
- if ( sc->sc_extendedops != NULL ) ldap_charray_free( sc->sc_extendedops );
+ if ( sc->sc_extendedops != NULL ) {
+ ldap_charray_free( sc->sc_extendedops );
+ }
ch_free( sc );
return LDAP_NO_MEMORY;
}
slap_known_controls[0] = ch_strdup( sc->sc_oid );
slap_known_controls[1] = NULL;
+
} else {
- for ( i = 0; slap_known_controls[i] != NULL; i++ )
- ;
- slap_known_controls = (char **)SLAP_REALLOC( slap_known_controls, (i + 2) * sizeof(char *) );
- if ( slap_known_controls == NULL ) {
- if ( sc->sc_extendedops != NULL ) ldap_charray_free( sc->sc_extendedops );
+ char **new_known_controls;
+
+ for ( i = 0; slap_known_controls[i] != NULL; i++ ) {
+ /* EMPTY */ ;
+ }
+
+ new_known_controls = (char **)SLAP_REALLOC(
+ slap_known_controls, (i + 2) * sizeof(char *) );
+
+ if ( new_known_controls == NULL ) {
+ if ( sc->sc_extendedops != NULL ) {
+ ldap_charray_free( sc->sc_extendedops );
+ }
ch_free( sc );
return LDAP_NO_MEMORY;
}
+ slap_known_controls = new_known_controls;
slap_known_controls[i++] = ch_strdup( sc->sc_oid );
slap_known_controls[i] = NULL;
}
LDAP_SLIST_NEXT( sc, sc_next ) = NULL;
LDAP_SLIST_INSERT_HEAD( &controls_list, sc, sc_next );
-
return LDAP_SUCCESS;
}
rc = register_supported_control( control_defs[i].sc_oid,
control_defs[i].sc_mask, control_defs[i].sc_extendedops,
control_defs[i].sc_parse );
- if ( rc != LDAP_SUCCESS )
- break;
+ if ( rc != LDAP_SUCCESS ) break;
}
return rc;
}
rc = sc->sc_parse( op, rs, c );
- assert( rc != LDAP_UNAVAILABLE_CRITICAL_EXTENSION );
if ( rc ) {
+ assert( rc != LDAP_UNAVAILABLE_CRITICAL_EXTENSION );
rs->sr_err = rc;
goto return_results;
}
}
#ifdef LDAP_SLAPI
- slapi_int_get_extop_plugin( &op->ore_reqoid, &funcAddr ); /* NS-SLAPI extended operation */
+ /* NS-SLAPI extended operation */
+ slapi_int_get_extop_plugin( &op->ore_reqoid, &funcAddr );
+
if( !funcAddr && !(ext = find_extop(supp_ext_list, &op->ore_reqoid )))
#else
if( !(ext = find_extop(supp_ext_list, &op->ore_reqoid )))
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
- "do_extended: conn %d oid=%s\n.", op->o_connid, op->ore_reqoid.bv_val, 0 );
+ "do_extended: conn %d oid=%s\n.",
+ op->o_connid, op->ore_reqoid.bv_val, 0 );
#else
- Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", op->ore_reqoid.bv_val, 0 ,0 );
+ Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n",
+ op->ore_reqoid.bv_val, 0 ,0 );
#endif
#if defined(LDAP_SLAPI)
if ( rs->sr_rspdata != NULL ) {
ber_bvfree( rs->sr_rspdata );
}
- } else { /* start of OpenLDAP extended operation */
+ } else
#endif /* defined( LDAP_SLAPI ) */
+ { /* start of OpenLDAP extended operation */
rs->sr_err = (ext->ext_main)( op, rs );
if( rs->sr_err != SLAPD_ABANDON ) {
if ( rs->sr_rspdata != NULL ) {
ber_bvfree( rs->sr_rspdata );
}
-#ifdef LDAP_SLAPI
} /* end of OpenLDAP extended operation */
-#endif /* LDAP_SLAPI */
done:;
return rs->sr_err;