]> git.sur5r.net Git - openldap/commitdiff
back out hex RID
authorPierangelo Masarati <ando@openldap.org>
Tue, 2 Oct 2007 18:08:41 +0000 (18:08 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 2 Oct 2007 18:08:41 +0000 (18:08 +0000)
servers/slapd/ldapsync.c
servers/slapd/slap.h
servers/slapd/syncrepl.c

index fc324bc0bf935d2a44ab11231406a464526aeaa0..8fca2903e668fd2fc3a59c2a015d9efb00448d04 100644 (file)
@@ -51,7 +51,7 @@ slap_compose_sync_cookie(
                        len = 0;
                } else {
                        len = snprintf( cookiestr, sizeof( cookiestr ),
-                                       "rid=%03x", rid );
+                                       "rid=%03d", rid );
                        if ( sid >= 0 ) {
                                len += sprintf( cookiestr+len, ",sid=%03x", sid );
                        }
@@ -72,7 +72,7 @@ slap_compose_sync_cookie(
 
                cookie->bv_val = slap_sl_malloc( len, op ? op->o_tmpmemctx : NULL );
 
-               len = sprintf( cookie->bv_val, "rid=%03x,", rid );
+               len = sprintf( cookie->bv_val, "rid=%03d,", rid );
                ptr = cookie->bv_val + len;
                if ( sid >= 0 ) {
                        ptr += sprintf( ptr, "sid=%03x,", sid );
@@ -174,7 +174,6 @@ slap_parse_sync_cookie(
 {
        char *csn_ptr;
        char *csn_str;
-       char *rid_ptr;
        char *cval;
        char *next, *end;
        AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp;
@@ -195,11 +194,13 @@ slap_parse_sync_cookie(
 
        for ( next=cookie->octet_str.bv_val; next < end; ) {
                if ( !strncmp( next, "rid=", STRLENOF("rid=") )) {
-                       rid_ptr = next;
-                       cookie->rid = strtoul( &rid_ptr[ STRLENOF( "rid=" ) ], &next, 10 );
+                       char *rid_ptr = next;
+                       cookie->rid = strtol( &rid_ptr[ STRLENOF( "rid=" ) ], &next, 10 );
                        if ( next == rid_ptr ||
                                next > end ||
-                               ( *next && *next != ',' ) )
+                               ( *next && *next != ',' ) ||
+                               cookie->rid < 0 ||
+                               cookie->rid > SLAP_SYNC_RID_MAX )
                        {
                                return -1;
                        }
@@ -212,11 +213,14 @@ slap_parse_sync_cookie(
                        continue;
                }
                if ( !strncmp( next, "sid=", STRLENOF("sid=") )) {
-                       rid_ptr = next;
-                       cookie->sid = strtoul( &rid_ptr[ STRLENOF( "sid=" ) ], &next, 16 );
-                       if ( next == rid_ptr ||
+                       char *sid_ptr = next;
+                       sid_ptr = next;
+                       cookie->sid = strtol( &sid_ptr[ STRLENOF( "sid=" ) ], &next, 16 );
+                       if ( next == sid_ptr ||
                                next > end ||
-                               ( *next && *next != ',' ) )
+                               ( *next && *next != ',' ) ||
+                               cookie->sid < 0 ||
+                               cookie->sid > SLAP_SYNC_SID_MAX )
                        {
                                return -1;
                        }
index 65319e1a6ef0955e7115a77c4950eef92c9469b9..bf181aeb9e14b07e3e461ff20683e085ff9e2e02 100644 (file)
@@ -1675,7 +1675,7 @@ typedef BackendDB Backend;
 
 struct syncinfo_s;
 
-#define SLAP_SYNC_RID_SIZE     3
+#define SLAP_SYNC_RID_MAX      999
 #define SLAP_SYNC_SID_MAX      4095    /* based on liblutil/csn.c field width */
 #define SLAP_SYNCUUID_SET_SIZE 256
 
index 11e38ac36f47e807ffe93a4cc504c0e6b866dd3d..3499f94fe498fae2d9d2051c40114d602a6437e6 100644 (file)
@@ -63,7 +63,7 @@ typedef struct syncinfo_s {
        BackendDB               *si_wbe;
        struct re_s             *si_re;
        int                     si_rid;
-       char                    si_ridtxt[ STRLENOF("rid=4095") + 1 ];
+       char                    si_ridtxt[ STRLENOF("rid=999") + 1 ];
        slap_bindconf           si_bindconf;
        struct berval           si_base;
        struct berval           si_logbase;
@@ -1277,16 +1277,16 @@ reload:
        if ( rc ) {
                if ( fail == RETRYNUM_TAIL ) {
                        Debug( LDAP_DEBUG_ANY,
-                               "do_syncrepl: rid %03d quitting\n",
-                               si->si_rid, 0, 0 );
+                               "do_syncrepl: %s quitting\n",
+                               si->si_ridtxt, 0, 0 );
                } else if ( fail > 0 ) {
                        Debug( LDAP_DEBUG_ANY,
-                               "do_syncrepl: rid %03d retrying (%d retries left)\n",
-                               si->si_rid, fail, 0 );
+                               "do_syncrepl: %s retrying (%d retries left)\n",
+                               si->si_ridtxt, fail, 0 );
                } else {
                        Debug( LDAP_DEBUG_ANY,
-                               "do_syncrepl: rid %03d retrying\n",
-                               si->si_rid, 0, 0 );
+                               "do_syncrepl: %s retrying\n",
+                               si->si_ridtxt, 0, 0 );
                }
        }
 
@@ -3002,8 +3002,6 @@ nonpresent_callback(
 
        } else if ( rs->sr_type == REP_SEARCH ) {
                if ( !( si->si_refreshDelete & NP_DELETE_ONE ) ) {
-                       char buf[sizeof("rid=4096 not")];
-
                        a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID );
 
                        if ( a ) {
@@ -3011,13 +3009,15 @@ nonpresent_callback(
                                        syncuuid_cmp );
                        }
 
-                       if ( slap_debug & LDAP_DEBUG_SYNC ) {
+                       if ( LogTest( LDAP_DEBUG_SYNC ) ) {
+                               char buf[sizeof("rid=999 not")];
+
                                snprintf( buf, sizeof(buf), "%s %s", si->si_ridtxt,
                                        present_uuid ? "got" : "not" );
-                       }
 
-                       Debug( LDAP_DEBUG_SYNC, "nonpresent_callback: %s UUID %s, dn %s\n",
-                               buf, a ? a->a_vals[0].bv_val : "<missing>", rs->sr_entry->e_name.bv_val );
+                               Debug( LDAP_DEBUG_SYNC, "nonpresent_callback: %s UUID %s, dn %s\n",
+                                       buf, a ? a->a_vals[0].bv_val : "<missing>", rs->sr_entry->e_name.bv_val );
+                       }
 
                        if ( a == NULL ) return 0;
                }
@@ -3383,7 +3383,7 @@ parse_syncrepl_line(
                                return -1;
                        }
                        si->si_rid = tmp;
-                       sprintf( si->si_ridtxt, IDSTR "=%d", si->si_rid );
+                       sprintf( si->si_ridtxt, IDSTR "=%03d", si->si_rid );
                        gots |= GOT_ID;
                } else if ( !strncasecmp( c->argv[ i ], PROVIDERSTR "=",
                                        STRLENOF( PROVIDERSTR "=" ) ) )
@@ -3930,7 +3930,7 @@ syncrepl_unparse( syncinfo_t *si, struct berval *bv )
 
        ptr = buf;
        assert( si->si_rid >= 0 && si->si_rid <= SLAP_SYNC_SID_MAX );
-       ptr += snprintf( ptr, WHATSLEFT, IDSTR "=%d " PROVIDERSTR "=%s",
+       ptr += snprintf( ptr, WHATSLEFT, IDSTR "=%03d " PROVIDERSTR "=%s",
                si->si_rid, si->si_bindconf.sb_uri.bv_val );
        if ( ptr - buf >= sizeof( buf ) ) return;
        if ( !BER_BVISNULL( &bc ) ) {