]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/sssvlv.c
Merge remote-tracking branch 'origin/mdb.master'
[openldap] / servers / slapd / overlays / sssvlv.c
index 160ba485bf7997343bbd3176f95aa6a01fcd4ab6..ec43fb87bdf16b491071ac976f140f835c9e85f8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2009-2011 The OpenLDAP Foundation.
+ * Copyright 2009-2012 The OpenLDAP Foundation.
  * Portions copyright 2009 Symas Corporation.
  * All rights reserved.
  *
@@ -436,6 +436,8 @@ static void send_list(
        Entry *e;
        LDAPControl *ctrls[2];
 
+       rs->sr_attrs = op->ors_attrs;
+
        /* FIXME: it may be better to just flatten the tree into
         * an array before doing all of this...
         */
@@ -515,8 +517,10 @@ range_err:
                }
                cur_node = tavl_find3( so->so_tree, sn, node_cmp, &j );
                /* didn't find >= match */
-               if ( j > 0 )
-                       cur_node = NULL;
+               if ( j > 0 ) {
+                       if ( cur_node )
+                               cur_node = tavl_next( cur_node, TAVL_DIR_RIGHT );
+               }
                op->o_tmpfree( sn, op->o_tmpmemctx );
 
                if ( !cur_node ) {
@@ -534,7 +538,7 @@ range_err:
                        }
                        for (i=0; tmp_node != cur_node;
                                tmp_node = tavl_next( tmp_node, dir ), i++);
-                       so->so_vlv_target = i;
+                       so->so_vlv_target = (dir == TAVL_DIR_RIGHT) ? i+1 : so->so_nentries - i;
                }
                if ( bv.bv_val != vc->vc_value.bv_val )
                        op->o_tmpfree( bv.bv_val, op->o_tmpmemctx );
@@ -584,6 +588,8 @@ static void send_page( Operation *op, SlapReply *rs, sort_op *so )
        Entry *e;
        int rc;
 
+       rs->sr_attrs = op->ors_attrs;
+
        while ( cur_node && rs->sr_nentries < so->so_page_size ) {
                sort_node *sn = cur_node->avl_data;
 
@@ -873,6 +879,9 @@ static int sssvlv_op_search(
        }
        ldap_pvt_thread_mutex_unlock( &sort_conns_mutex );
        if ( ok ) {
+               /* If we're a global overlay, this check got bypassed */
+               if ( !op->ors_limit && limits_check( op, rs ))
+                       return rs->sr_err;
                /* are we continuing a VLV search? */
                if ( so && vc && vc->vc_context ) {
                        so->so_ctrl = sc;
@@ -1067,6 +1076,9 @@ static int build_key(
        return rs->sr_err;
 }
 
+/* Conforms to RFC4510 re: Criticality, original RFC2891 spec is broken
+ * Also see ITS#7253 for discussion
+ */
 static int sss_parseCtrl(
        Operation               *op,
        SlapReply               *rs,