]> git.sur5r.net Git - openldap/commitdiff
ITS#2808 fix UUIDNormalize, use it.
authorHoward Chu <hyc@openldap.org>
Mon, 3 Nov 2003 08:22:13 +0000 (08:22 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 3 Nov 2003 08:22:13 +0000 (08:22 +0000)
servers/slapd/modify.c
servers/slapd/schema_init.c
servers/slapd/syncrepl.c

index 10298b5c781fa0348304b259835d08d097755ec0..eebb174c0dfa1aeb648b8f4a1060a1c3ac26fbb8 100644 (file)
@@ -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;
 
index a3cd70f295b0159d874af52bee4be9eb0581468a..0885ff036110a0c1e2a65fe77d02a857343b3c77 100644 (file)
@@ -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++;
        }
index 486be51aae407edecfee9753227a12796d569509..b7d4528d64e71b55a7e2f4ab2d3204e311202417 100644 (file)
@@ -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 );
        }