From: Howard Chu Date: Wed, 11 Feb 2009 22:00:00 +0000 (+0000) Subject: Add some asserts on CSN validity X-Git-Tag: ACLCHECK_0~835 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=686ceac31f1c4f2d7f59362ea830d650a9ca4bcd;p=openldap Add some asserts on CSN validity --- diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 2f8686acec..08800c1b2b 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1339,7 +1339,14 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on ) SlapReply rsm = { 0 }; slap_callback cb = {0}; BackendDB be; +#ifdef CHECK_CSN + Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax; + int i; + for ( i=0; isi_numcsns; i++ ) { + assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i )); + } +#endif mod.sml_numvals = si->si_numcsns; mod.sml_values = si->si_ctxcsn; mod.sml_nvalues = NULL; @@ -1367,6 +1374,11 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on ) if ( mod.sml_next != NULL ) { slap_mods_free( mod.sml_next, 1 ); } +#ifdef CHECK_CSN + for ( i=0; isi_numcsns; i++ ) { + assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i )); + } +#endif } static void diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 1313b8ad42..d99af0ef2e 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -2876,6 +2876,9 @@ syncrepl_updateCookie( Backend *be = op->o_bd; Modifications mod; struct berval first = BER_BVNULL; +#ifdef CHECK_CSN + Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax; +#endif int rc, i, j; ber_len_t len; @@ -2892,6 +2895,15 @@ syncrepl_updateCookie( ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex ); +#ifdef CHECK_CSN + for ( i=0; inumcsns; i++ ) { + assert( !syn->ssyn_validate( syn, syncCookie->ctxcsn+i )); + } + for ( i=0; isi_cookieState->cs_num; i++ ) { + assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i )); + } +#endif + /* clone the cookieState CSNs so we can Replace the whole thing */ mod.sml_numvals = si->si_cookieState->cs_num; mod.sml_values = op->o_tmpalloc(( mod.sml_numvals+1 )*sizeof(struct berval), op->o_tmpmemctx ); @@ -2994,6 +3006,12 @@ syncrepl_updateCookie( if ( mod.sml_next ) slap_mods_free( mod.sml_next, 1 ); op->o_tmpfree( mod.sml_values, op->o_tmpmemctx ); +#ifdef CHECK_CSN + for ( i=0; isi_cookieState->cs_num; i++ ) { + assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i )); + } +#endif + return rc; }