]> git.sur5r.net Git - openldap/commitdiff
csn format update & cleanup
authorJong Hyuk Choi <jongchoi@openldap.org>
Tue, 18 Nov 2003 22:42:13 +0000 (22:42 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Tue, 18 Nov 2003 22:42:13 +0000 (22:42 +0000)
servers/slapd/ldapsync.c

index b936dfef8fc569733f9857ffba70d01e515acb48..fd33731a0fa9ff494ee0dfad9bbfd5c1d1402f2c 100644 (file)
@@ -356,10 +356,9 @@ slap_parse_sync_cookie(
 {
        char *csn_ptr;
        char *csn_str;
-       char *csn_str_val;
+       int csn_str_len;
        char *sid_ptr;
        char *sid_str;
-       char *sid_str_val;
        char *cval;
        struct berval *ctxcsn;
 
@@ -368,11 +367,16 @@ slap_parse_sync_cookie(
 
        if (( csn_ptr = strstr( cookie->octet_str[0].bv_val, "csn=" )) != NULL ) {
                csn_str = (char *) SLAP_STRNDUP( csn_ptr, LDAP_LUTIL_CSNSTR_BUFSIZE );
-               csn_str_val = csn_str + sizeof("csn=") - 1;
                if ( cval = strchr( csn_str, ',' )) {
                        *cval = '\0';
+                       csn_str_len = cval - csn_str - (sizeof("csn=") - 1);
+               } else {
+                       csn_str_len = cookie->octet_str[0].bv_len -
+                                                       (csn_ptr - cookie->octet_str[0].bv_val) -
+                                                       (sizeof("csn=") - 1);
                }
-               ctxcsn = ber_str2bv( csn_str_val, strlen(csn_str_val), 1, NULL );
+               ctxcsn = ber_str2bv( csn_str + (sizeof("csn=")-1),
+                                                        csn_str_len, 1, NULL );
                ch_free( csn_str );
                ber_bvarray_add( &cookie->ctxcsn, ctxcsn );
                ch_free( ctxcsn );
@@ -383,11 +387,10 @@ slap_parse_sync_cookie(
        if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) {
                sid_str = (char *) SLAP_STRNDUP( sid_ptr,
                                                        SLAP_SYNC_SID_SIZE + sizeof("sid=") - 1 );
-               sid_str_val = sid_str + sizeof("sid=") - 1;
                if ( cval = strchr( sid_str, ',' )) {
                        *cval = '\0';
                }
-               cookie->sid = atoi( sid_str_val );
+               cookie->sid = atoi( sid_str + sizeof("sid=") - 1 );
                ch_free( sid_str );
        } else {
                cookie->sid = -1;
@@ -409,7 +412,7 @@ slap_init_sync_cookie_ctxcsn(
                return -1;
 
        octet_str.bv_len = snprintf( csnbuf, LDAP_LUTIL_CSNSTR_BUFSIZE + 4,
-                                       "csn=%4d%02d%02d%02d:%02d:%02dZ#0x%04x#%d#%04x",
+                                       "csn=%4d%02d%02d%02d%02d%02dZ#%06x#%02x#%06x",
                                        1900, 1, 1, 0, 0, 0, 0, 0, 0 );
        octet_str.bv_val = csnbuf;
        build_new_dn( &slap_syncCookie, &cookie->octet_str[0], &octet_str, NULL );