From c0490482d6ed3e065e30b906385d523bab39974b Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 12 Jun 2004 17:37:37 +0000 Subject: [PATCH] ignore the control if page is larger than requested sizelimit (as per RFC) --- servers/slapd/controls.c | 37 ++++++++++++++++++++++++++++++++++--- servers/slapd/slap.h | 3 ++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 20ae28a052..43e95ec0ec 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -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 ) ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 0a36d8da30..0a51ee120a 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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 -- 2.39.5