]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/modify.c
liberally accept many LDAPv2/LDAPv3 stuff in DN (quoted parts, ';' as rdn separator...
[openldap] / servers / slapd / modify.c
index 4bc3b0c41ef2a91b618d7a8b33dffb122e2f01fb..313c13460255790c796c77f228dfb0769efc9b26 100644 (file)
@@ -490,8 +490,10 @@ int slap_modlist2mods(
                        ber_len_t nvals;
                        slap_syntax_validate_func *validate =
                                ad->ad_type->sat_syntax->ssyn_validate;
-
-                       if( !validate ) {
+                       slap_syntax_transform_func *pretty =
+                               ad->ad_type->sat_syntax->ssyn_pretty;
+                       if( !pretty && !validate ) {
                                slap_mods_free( mod );
                                *text = "no validator for syntax";
                                snprintf( textbuf, textlen,
@@ -504,9 +506,17 @@ int slap_modlist2mods(
 
                        /*
                         * check that each value is valid per syntax
+                        *      and pretty if appropriate
                         */
                        for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
-                               rc = validate( ad->ad_type->sat_syntax, ml->ml_bvalues[nvals] );
+                               struct berval *pval;
+                               if( pretty ) {
+                                       rc = pretty( ad->ad_type->sat_syntax,
+                                               ml->ml_bvalues[nvals], &pval );
+                               } else {
+                                       rc = validate( ad->ad_type->sat_syntax,
+                                               ml->ml_bvalues[nvals] );
+                               }
 
                                if( rc != 0 ) {
                                        slap_mods_free( mod );
@@ -516,6 +526,12 @@ int slap_modlist2mods(
                                        *text = textbuf;
                                        return LDAP_INVALID_SYNTAX;
                                }
+
+                               if( pretty ) {
+                                       ber_memfree( ml->ml_bvalues[nvals]->bv_val );
+                                       *ml->ml_bvalues[nvals] = *pval;
+                                       free( pval );
+                               }
                        }
 
                        /*
@@ -552,7 +568,7 @@ int slap_mods_opattrs(
        struct berval name, timestamp, csn;
        time_t now = slap_get_time();
        char timebuf[22];
-       char csnbuf[128];
+       char csnbuf[64];
        struct tm *ltm;
        Modifications *mod;
 
@@ -583,7 +599,7 @@ int slap_mods_opattrs(
 
        if( op->o_tag == LDAP_REQ_ADD ) {
                struct berval uuid;
-               char uuidbuf[64];
+               char uuidbuf[40];
 
                uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
                uuid.bv_val = uuidbuf;