From: Howard Chu Date: Mon, 8 Aug 2005 23:56:40 +0000 (+0000) Subject: ITS#3917 don't check csn syntax if schema isn't inited yet X-Git-Tag: OPENLDAP_AC_BP~36 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0b2a428a291723a3faff3d07fa578441a926b62d;p=openldap ITS#3917 don't check csn syntax if schema isn't inited yet --- diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 2905903777..9d335860df 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -95,17 +95,33 @@ slap_parse_sync_cookie( 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 ) @@ -131,17 +147,6 @@ slap_parse_sync_cookie( 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; } diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 4f6360f626..02becaa502 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -362,8 +362,18 @@ int main( int argc, char **argv ) 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, diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index e944dc5724..cba7f7e813 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -482,6 +482,8 @@ do_syncrep1( 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 */