From: Howard Chu Date: Sat, 9 Apr 2005 10:00:15 +0000 (+0000) Subject: Don't crash on update_ctx if context entry has no contextCSN X-Git-Tag: OPENLDAP_AC_BP~950 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=632d7186c06e667b38368c41f01a125bc87b78c3;p=openldap Don't crash on update_ctx if context entry has no contextCSN --- diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index 8648e2e2ba..2235c54dbf 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -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",