]> git.sur5r.net Git - openldap/commitdiff
ITS#4952 use memcmp to compare CSN values
authorHoward Chu <hyc@openldap.org>
Thu, 10 May 2007 18:46:15 +0000 (18:46 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 10 May 2007 18:46:15 +0000 (18:46 +0000)
servers/slapd/syncrepl.c

index 039fbb37f2535baa08ca0122072b853a2a651dc6..582df0f2d0ec766384fce7f1d052bf9b3748fb19 100644 (file)
@@ -2537,7 +2537,7 @@ syncrepl_updateCookie(
        Modifications mod[2];
        struct berval first = BER_BVNULL;
 
-       int rc, i, j;
+       int rc, i, j, len;
 
        slap_callback cb = { NULL };
        SlapReply       rs_modify = {REP_RESULT};
@@ -2562,8 +2562,11 @@ syncrepl_updateCookie(
                for ( j=0; j<si->si_cookieState->cs_num; j++ ) {
                        if ( syncCookie->sids[i] != si->si_cookieState->cs_sids[j] )
                                continue;
-                       if ( ber_bvcmp( &syncCookie->ctxcsn[i],
-                               &si->si_cookieState->cs_vals[j] ) > 0 ) {
+                       len = syncCookie->ctxcsn[i].bv_len;
+                       if ( len > si->si_cookieState->cs_vals[j].bv_len )
+                               len = si->si_cookieState->cs_vals[j].bv_len;
+                       if ( memcmp( syncCookie->ctxcsn[i].bv_val,
+                               &si->si_cookieState->cs_vals[j].bv_val, len ) > 0 ) {
                                ber_bvarray_add_x( &mod[0].sml_values,
                                        &si->si_cookieState->cs_vals[j], op->o_tmpmemctx );
                                ber_bvarray_add_x( &mod[1].sml_values,
@@ -2845,15 +2848,20 @@ dn_callback(
                                        slap_schema.si_ad_entryCSN );
                                new = attr_find( dni->new_entry->e_attrs,
                                        slap_schema.si_ad_entryCSN );
-                               if ( new && old && ber_bvcmp( &old->a_vals[0],
-                                       &new->a_vals[0] ) >= 0 ) {
-                                       Debug( LDAP_DEBUG_SYNC,
-                                               "dn_callback : new entry is older than ours "
-                                               "%s ours %s, new %s\n",
-                                               rs->sr_entry->e_name.bv_val,
-                                               old->a_vals[0].bv_val,
-                                               new->a_vals[0].bv_val );
-                                       return LDAP_SUCCESS;
+                               if ( new && old ) {
+                                       int len = old->a_vals[0].bv_len;
+                                       if ( len > new->a_vals[0].bv_len )
+                                               len = new->a_vals[0].bv_len;
+                                       if ( memcmp( old->a_vals[0].bv_val,
+                                               new->a_vals[0].bv_val, len ) >= 0 ) {
+                                               Debug( LDAP_DEBUG_SYNC,
+                                                       "dn_callback : new entry is older than ours "
+                                                       "%s ours %s, new %s\n",
+                                                       rs->sr_entry->e_name.bv_val,
+                                                       old->a_vals[0].bv_val,
+                                                       new->a_vals[0].bv_val );
+                                               return LDAP_SUCCESS;
+                                       }
                                }
 
                                /* We assume that attributes are saved in the same order