]> git.sur5r.net Git - openldap/commitdiff
ignore the control if page is larger than requested sizelimit (as per RFC)
authorPierangelo Masarati <ando@openldap.org>
Sat, 12 Jun 2004 17:37:37 +0000 (17:37 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 12 Jun 2004 17:37:37 +0000 (17:37 +0000)
servers/slapd/controls.c
servers/slapd/slap.h

index 20ae28a05299473ef278cb9f68410ab1d7ef3aa4..43e95ec0eceafff3e5a1f4b5624d9d9e38f8ef3d 100644 (file)
@@ -598,6 +598,7 @@ int get_ctrls(
 
                        if (( sc->sc_mask & tagmask ) == tagmask ) {
                                /* available extension */
+                               int     rc;
 
                                if( !sc->sc_parse ) {
                                        rs->sr_err = LDAP_OTHER;
@@ -605,9 +606,24 @@ int get_ctrls(
                                        goto return_results;
                                }
 
-                               rs->sr_err = sc->sc_parse( op, rs, c );
-                               assert( rs->sr_err != LDAP_UNAVAILABLE_CRITICAL_EXTENSION );
-                               if( rs->sr_err != LDAP_SUCCESS ) goto return_results;
+                               rc = sc->sc_parse( op, rs, c );
+                               assert( rc != LDAP_UNAVAILABLE_CRITICAL_EXTENSION );
+                               switch ( rc ) {
+                               /* for some reason, the control should be ignored */
+                               case SLAP_CTRL_IGNORE:
+                                       op->o_tmpfree( c, op->o_tmpmemctx );
+                                       op->o_ctrls[--nctrls] = NULL;
+                                       goto next_ctrl;
+                               
+                               /* the control was successfully parsed */
+                               case LDAP_SUCCESS:
+                                       break;
+
+                               /* something happened... */
+                               default:
+                                       rs->sr_err = rc;
+                                       goto return_results;
+                               }
 
                                if ( sc->sc_mask & SLAP_CTRL_FRONTEND ) {
                                        /* kludge to disable backend_control() check */
@@ -633,6 +649,7 @@ int get_ctrls(
                        rs->sr_text = "critical extension is not recognized";
                        goto return_results;
                }
+next_ctrl:;
        }
 
 return_results:
@@ -885,6 +902,20 @@ static int parsePagedResults (
                return LDAP_PROTOCOL_ERROR;
        }
 
+       /*
+        * NOTE: according to RFC 2696 3.:
+        *
+            If the page size is greater than or equal to the sizeLimit value, the
+            server should ignore the control as the request can be satisfied in a
+            single page.
+        *
+        * NOTE: this assumes that the op->ors_slimit be set before the controls
+        * are parsed.
+        */
+       if ( op->ors_slimit > 0 && size >= op->ors_slimit ) {
+               return SLAP_CTRL_IGNORE;
+       }
+
        if( cookie.bv_len ) {
                PagedResultsCookie reqcookie;
                if( cookie.bv_len != sizeof( reqcookie ) ) {
index 0a36d8da30a2ec14b0aea6c28f8263bececde35a..0a51ee120a066c20b8c9413f436caa04dd37de32 100644 (file)
@@ -2376,7 +2376,8 @@ enum {
 #endif
 
 #define SLAP_CTRL_FRONTEND                     0x00800000U
-#define SLAP_CTRL_FRONTEND_SEARCH      0x00010000U     /* for NOOP */
+#define SLAP_CTRL_FRONTEND_SEARCH              0x00010000U     /* for NOOP */
+#define SLAP_CTRL_IGNORE                       0x00020000U
 
 #define SLAP_CTRL_OPFLAGS                      0x0000FFFFU
 #define SLAP_CTRL_ABANDON                      0x00000001U