]> git.sur5r.net Git - openldap/commitdiff
SLAPD_SCHEMA_NOT_COMPAT: fix bugs in add/modify logic
authorKurt Zeilenga <kurt@openldap.org>
Tue, 23 May 2000 18:08:19 +0000 (18:08 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 23 May 2000 18:08:19 +0000 (18:08 +0000)
servers/slapd/add.c
servers/slapd/modify.c
servers/slapd/schema_check.c

index 97b618ce277082dd73ed0a092ef147ff0227f7e8..8593bf1e290a02cc3bebc9519e16733ddd2ff43b 100644 (file)
@@ -233,7 +233,15 @@ do_add( Connection *conn, Operation *op )
 #endif
                        {
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-                               rc = slap_mods_opattrs( op, &mods, &text );
+                               Modifications **modstail;
+                               for( modstail = &mods;
+                                       *modstail != NULL;
+                                       modstail = &(*modstail)->sml_next )
+                               {
+                                       assert( (*modstail)->sml_op == LDAP_MOD_ADD );
+                                       assert( (*modstail)->sml_desc != NULL );
+                               }
+                               rc = slap_mods_opattrs( op, modstail, &text );
 #else
                                char *text = "no-user-modification attribute type";
                                rc = add_created_attrs( op, e );
@@ -307,6 +315,7 @@ static int slap_mods2entry(
                Attribute *attr;
 
                assert( mods->sml_op == LDAP_MOD_ADD );
+               assert( mods->sml_desc != NULL );
 
                attr = attr_find( (*e)->e_attrs, mods->sml_desc );
 
@@ -317,7 +326,12 @@ static int slap_mods2entry(
 
                attr = ch_calloc( 1, sizeof(Attribute) );
 
-               /* should check for duplicates */
+               /* move ad to attr structure */
+               attr->a_desc = mods->sml_desc;
+               mods->sml_desc = NULL;
+
+               /* move values to attr structure */
+               /*      should check for duplicates */
                attr->a_vals = mods->sml_bvalues;
                mods->sml_bvalues = NULL;
 
index 38f6038300152a51e87bf4d376bc332345204364..0921238ad6a8cc8d69e26c9615f06cafcec0e60f 100644 (file)
@@ -235,7 +235,14 @@ do_modify(
                                global_lastmod == ON)) && !update )
                        {
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-                               rc = slap_mods_opattrs( op, &mods, &text );
+                               Modifications **modstail;
+                               for( modstail = &mods;
+                                       *modstail != NULL;
+                                       modstail = &(*modstail)->sml_next )
+                               {
+                                       /* empty */
+                               }
+                               rc = slap_mods_opattrs( op, modstail, &text );
 #else
                                char *text = "no-user-modification attribute type";
                                rc = add_modified_attrs( op, &mods );
@@ -303,16 +310,16 @@ int slap_modlist2mods(
                mod = (Modifications *)
                        ch_calloc( 1, sizeof(Modifications) );
 
-               ad = mod->sml_desc;
-
                /* convert to attribute description */
-               rc = slap_str2ad( ml->ml_type, &ad, text );
+               rc = slap_str2ad( ml->ml_type, &mod->sml_desc, text );
 
                if( rc != LDAP_SUCCESS ) {
                        slap_mods_free( mod );
                        return rc;
                }
 
+               ad = mod->sml_desc;
+
                if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
                        && !slap_ad_is_binary( ad ))
                {
@@ -405,6 +412,9 @@ int slap_mods_opattrs(
        int mop = op->o_tag == LDAP_REQ_ADD
                ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
 
+       assert( modtail != NULL );
+       assert( *modtail == NULL );
+
        ldap_pvt_thread_mutex_lock( &gmtime_mutex );
        ltm = gmtime( &now );
        strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
index da8559e53580a1dbaeacaad716173e1b21948055..c10f50e94bd3463e6971e09123784c08170d9e56 100644 (file)
@@ -52,6 +52,7 @@ entry_schema_check(
        if ( (aoc = attr_find( e->e_attrs, ad_objectClass )) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n",
                    e->e_dn, 0, 0 );
+               assert(0);
 
                *text = "no objectclass attribute";
                return oldattrs != NULL