+ if ( ndn->bv_len == 0 ) {
+ break;
+ }
+ if ( dn_match( &lm[0]->lm_dn_pat, ndn ) ) {
+ *limit = &lm[0]->lm_limits;
+ return( 0 );
+ }
+ break;
+
+ case SLAP_LIMITS_ONE:
+ case SLAP_LIMITS_SUBTREE:
+ case SLAP_LIMITS_CHILDREN: {
+ size_t d;
+
+ if ( ndn->bv_len == 0 ) {
+ break;
+ }
+
+ /* ndn shorter than dn_pat */
+ if ( ndn->bv_len < lm[0]->lm_dn_pat.bv_len ) {
+ break;
+ }
+ d = ndn->bv_len - lm[0]->lm_dn_pat.bv_len;
+
+ /* allow exact match for SUBTREE only */
+ if ( d == 0 ) {
+ if ( lm[0]->lm_type != SLAP_LIMITS_SUBTREE ) {
+ break;
+ }
+ } else {
+ /* check for unescaped rdn separator */
+ if ( !DN_SEPARATOR( ndn->bv_val[d-1] ) ) {
+ break;
+ }
+ }
+
+ /* in case of (sub)match ... */
+ if ( lm[0]->lm_dn_pat.bv_len == ( ndn->bv_len - d )
+ && strcmp( lm[0]->lm_dn_pat.bv_val, &ndn->bv_val[d] ) == 0 ) {
+ /* check for exactly one rdn in case of ONE */
+ if ( lm[0]->lm_type == SLAP_LIMITS_ONE ) {
+ /*
+ * if ndn is more that one rdn
+ * below dn_pat, continue
+ */
+ if ( (size_t) dn_rdnlen( NULL, ndn ) != d - 1 ) {
+ break;
+ }
+ }
+