int csn_str_len;
int valid = 0;
char *rid_ptr;
- char *rid_str;
char *cval;
if ( cookie == NULL )
return -1;
+ cookie->rid = -1;
+ if (( rid_ptr = strstr( cookie->octet_str.bv_val, "rid=" )) != NULL ) {
+ if ( (cval = strchr( rid_ptr, ',' )) != NULL ) {
+ *cval = '\0';
+ }
+ cookie->rid = atoi( rid_ptr + sizeof("rid=") - 1 );
+ if ( cval != NULL ) {
+ *cval = ',';
+ }
+ } else {
+ return -1;
+ }
+
while (( csn_ptr = strstr( cookie->octet_str.bv_val, "csn=" )) != NULL ) {
AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp;
slap_syntax_validate_func *validate;
struct berval stamp;
+ /* This only happens when called from main */
+ if ( ad == NULL )
+ break;
+
csn_str = csn_ptr + STRLENOF("csn=");
cval = strchr( csn_str, ',' );
if ( cval )
BER_BVZERO( &cookie->ctxcsn );
}
- if (( rid_ptr = strstr( cookie->octet_str.bv_val, "rid=" )) != NULL ) {
- rid_str = SLAP_STRNDUP( rid_ptr,
- SLAP_SYNC_RID_SIZE + sizeof("rid=") - 1 );
- if ( (cval = strchr( rid_str, ',' )) != NULL ) {
- *cval = '\0';
- }
- cookie->rid = atoi( rid_str + sizeof("rid=") - 1 );
- ch_free( rid_str );
- } else {
- cookie->rid = -1;
- }
return 0;
}
scp = (struct sync_cookie *) ch_calloc( 1,
sizeof( struct sync_cookie ));
ber_str2bv( optarg, 0, 1, &scp->octet_str );
+
+ /* This only parses out the rid at this point */
slap_parse_sync_cookie( scp, NULL );
+ if ( scp->rid == -1 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "main: invalid cookie \"%s\"\n",
+ optarg, 0, 0 );
+ slap_sync_cookie_free( scp, 1 );
+ goto destroy;
+ }
+
LDAP_STAILQ_FOREACH( scp_entry, &slap_sync_cookie, sc_next ) {
if ( scp->rid == scp_entry->rid ) {
Debug( LDAP_DEBUG_ANY,
LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
+ /* ctxcsn wasn't parsed yet, do it now */
+ slap_parse_sync_cookie( sc, op->o_tmpmemctx );
if ( BER_BVISNULL( &sc->ctxcsn ) ) {
/* if cmdline cookie does not have ctxcsn */
/* component, set it to an initial value */