From: Kurt Zeilenga Date: Sat, 2 Mar 2002 17:05:29 +0000 (+0000) Subject: Add validation. X-Git-Tag: OPENLDAP_REL_ENG_2_MP~380 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ad0858dea49bd3155d4ba210ee3afd923179f217;p=openldap Add validation. --- diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index d2308d9967..450691d326 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -242,6 +242,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) for ( iAVA = 0; rdn[ 0 ][ iAVA ]; iAVA++ ) { LDAPAVA *ava = rdn[ 0 ][ iAVA ]; AttributeDescription *ad; + slap_syntax_validate_func *validf = NULL; slap_syntax_transform_func *transf = NULL; MatchingRule *mr; struct berval bv = { 0, NULL }; @@ -268,17 +269,31 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) if( ava->la_flags & LDAP_AVA_BINARY ) { /* AVA is binary encoded, don't muck with it */ + validf = NULL; transf = NULL; mr = NULL; - } else if( flags & SLAP_LDAPDN_PRETTY ) { + validf = NULL; transf = ad->ad_type->sat_syntax->ssyn_pretty; mr = NULL; } else { + validf = ad->ad_type->sat_syntax->ssyn_validate; transf = ad->ad_type->sat_syntax->ssyn_normalize; mr = ad->ad_type->sat_equality; } + if ( validf ) { + /* validate value before normalization */ + rc = ( *validf )( ad->ad_type->sat_syntax, + ava->la_value.bv_len + ? &ava->la_value + : (struct berval *) &slap_empty_bv ); + + if ( rc != LDAP_SUCCESS ) { + return LDAP_INVALID_SYNTAX; + } + } + if ( transf ) { /* * transform value by normalize/pretty function