From: Howard Chu Date: Thu, 9 Dec 2004 08:49:54 +0000 (+0000) Subject: Add better validation of received cookie csn X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~80 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c83a74f4f3ccef6d20899da4c0cb8de15b7c6c58;p=openldap Add better validation of received cookie csn --- diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 1bd9e61fef..a19955c75e 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1744,9 +1744,29 @@ syncprov_op_search( Operation *op, SlapReply *rs ) sessionlog *sl; /* Is the CSN in a valid format? */ - if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) { - send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); - return rs->sr_err; + /* FIXME: should use csnValidate when that is implemented */ + { + char *ptr; + struct berval timestamp; + slap_syntax_validate_func *validate; + AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp; + + if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) { + send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); + return rs->sr_err; + } + ptr = strchr( srs->sr_state.ctxcsn->bv_val, '#' ); + if ( !ptr ) { + send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); + return rs->sr_err; + } + timestamp.bv_val = srs->sr_state.ctxcsn->bv_val; + timestamp.bv_len = ptr - timestamp.bv_val; + validate = ad->ad_type->sat_syntax->ssyn_validate; + if ( validate( ad->ad_type->sat_syntax, ×tamp )) { + send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); + return rs->sr_err; + } } /* If just Refreshing and nothing has changed, shortcut it */ if ( bvmatch( srs->sr_state.ctxcsn, &ctxcsn )) {