From: Howard Chu Date: Mon, 3 Nov 2003 08:22:13 +0000 (+0000) Subject: ITS#2808 fix UUIDNormalize, use it. X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~465 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ccf224a7592ff2559abbbfd26da4f854be6e40e8;p=openldap ITS#2808 fix UUIDNormalize, use it. --- diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 10298b5c78..eebb174c0d 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -855,7 +855,15 @@ int slap_mods_opattrs( mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); - mod->sml_nvalues = NULL; + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + (*mod->sml_desc->ad_type->sat_equality->smr_normalize)( + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, + mod->sml_desc->ad_type->sat_syntax, + mod->sml_desc->ad_type->sat_equality, + mod->sml_values, mod->sml_nvalues, NULL ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; *modtail = mod; modtail = &mod->sml_next; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index a3cd70f295..0885ff0361 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1835,11 +1835,11 @@ UUIDNormalize( return LDAP_INVALID_SYNTAX; } - if( j % 2 ) { - octet = nibble << 4; - } else { + if( j & 1 ) { octet |= nibble; normalized->bv_val[j>>1] = octet; + } else { + octet = nibble << 4; } j++; } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 486be51aae..b7d4528d64 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -895,6 +895,7 @@ syncrepl_entry( AttributeAssertion ava = {0}; int rc = LDAP_SUCCESS; int ret = LDAP_SUCCESS; + const char *text; if ( refresh && ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) @@ -908,6 +909,17 @@ syncrepl_entry( return e ? 1 : 0; } + f.f_choice = LDAP_FILTER_EQUALITY; + f.f_ava = &ava; + ava.aa_desc = slap_schema.si_ad_entryUUID; + rc = asserted_value_validate_normalize( + ava.aa_desc, ad_mr(ava.aa_desc, SLAP_MR_EQUALITY), + SLAP_MR_EQUALITY, syncUUID, &ava.aa_value, &text, op->o_tmpmemctx ); + if ( rc != LDAP_SUCCESS ) { + return rc; + } + op->ors_filter = &f; + op->ors_filterstr.bv_len = (sizeof("entryUUID=")-1) + syncUUID->bv_len; op->ors_filterstr.bv_val = (char *) sl_malloc( op->ors_filterstr.bv_len + 1, op->o_tmpmemctx ); @@ -916,11 +928,6 @@ syncrepl_entry( syncUUID->bv_val, syncUUID->bv_len ); op->ors_filterstr.bv_val[op->ors_filterstr.bv_len] = '\0'; - f.f_choice = LDAP_FILTER_EQUALITY; - f.f_ava = &ava; - ava.aa_desc = slap_schema.si_ad_entryUUID; - ava.aa_value = *syncUUID; - op->ors_filter = &f; op->ors_scope = LDAP_SCOPE_SUBTREE; /* get syncrepl cookie of shadow replica from subentry */ @@ -960,8 +967,8 @@ syncrepl_entry( rc == LDAP_NO_SUCH_OBJECT ) { attr_delete( &e->e_attrs, slap_schema.si_ad_entryUUID ); - attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, - syncUUID, op->o_tmpmemctx ); + attr_merge_one( e, slap_schema.si_ad_entryUUID, + syncUUID, &ava.aa_value ); op->o_tag = LDAP_REQ_ADD; op->ora_e = e; @@ -1050,6 +1057,9 @@ syncrepl_entry( done : + if ( ava.aa_value.bv_val ) { + ber_memfree_x( ava.aa_value.bv_val, op->o_tmpmemctx ); + } if ( si->si_syncUUID_ndn.bv_val ) { ber_memfree_x( si->si_syncUUID_ndn.bv_val, op->o_tmpmemctx ); }