mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
Validate values in tool mode
This commit is contained in:
parent
b6674a90b0
commit
9a8006a6c2
@ -117,6 +117,13 @@ str2entry( char *s )
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= str2entry: str2ad(%s): %s\n", type, text, 0 );
|
||||
|
||||
if( slapMode & SLAP_TOOL_MODE ) {
|
||||
entry_free( e );
|
||||
free( value.bv_val );
|
||||
free( type );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = slap_str2undef_ad( type, &ad, &text );
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
@ -126,7 +133,37 @@ str2entry( char *s )
|
||||
entry_free( e );
|
||||
free( value.bv_val );
|
||||
free( type );
|
||||
return( NULL );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( slapMode & SLAP_TOOL_MODE ) {
|
||||
slap_syntax_validate_func *validate =
|
||||
ad->ad_type->sat_syntax->ssyn_validate;
|
||||
|
||||
if( !validate ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"str2entry: no validator for syntax %s\n",
|
||||
ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
|
||||
entry_free( e );
|
||||
free( value.bv_val );
|
||||
free( type );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* validate value per syntax
|
||||
*/
|
||||
rc = validate( ad->ad_type->sat_syntax, &value );
|
||||
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"str2entry: invalid value for syntax %s\n",
|
||||
ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
|
||||
entry_free( e );
|
||||
free( value.bv_val );
|
||||
free( type );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user