]> git.sur5r.net Git - openldap/commitdiff
Don't crash on update_ctx if context entry has no contextCSN
authorHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 10:00:15 +0000 (10:00 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 10:00:15 +0000 (10:00 +0000)
servers/slapd/slapadd.c

index 8648e2e2bad9f52a508fec333d107f504d15d61c..2235c54dbf723064806c16049a4dcf7ddc9d4728 100644 (file)
@@ -335,15 +335,21 @@ done:;
                        if ( ret == LDAP_SUCCESS ) {
                                attr = attr_find( ctxcsn_e->e_attrs,
                                                                        slap_schema.si_ad_contextCSN );
-                               value_match( &match, slap_schema.si_ad_entryCSN,
-                                       slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
-                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                       &maxcsn, &attr->a_nvals[0], &text );
+                               if ( attr ) {
+                                       value_match( &match, slap_schema.si_ad_entryCSN,
+                                               slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
+                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                               &maxcsn, &attr->a_nvals[0], &text );
+                                       if ( match > 0 ) {
+                                               AC_MEMCPY( attr->a_vals[0].bv_val, maxcsn.bv_val, maxcsn.bv_len );
+                                               attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
+                                               attr->a_vals[0].bv_len = maxcsn.bv_len;
+                                       }
+                               } else {
+                                       match = 1;
+                                       attr_merge_one( ctxcsn_e, slap_schema.si_ad_contextCSN, &maxcsn, NULL );
+                               }
                                if ( match > 0 ) {
-                                       AC_MEMCPY( attr->a_vals[0].bv_val, maxcsn.bv_val, maxcsn.bv_len );
-                                       attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
-                                       attr->a_vals[0].bv_len = maxcsn.bv_len;
-                               
                                        ctxcsn_id = be->be_entry_modify( be, ctxcsn_e, &bvtext );
                                        if( ctxcsn_id == NOID ) {
                                                fprintf( stderr, "%s: could not modify ctxcsn\n",