]> git.sur5r.net Git - openldap/commitdiff
Fixed invalid cookie in pagedResults control (ITS#3089)
authorPierangelo Masarati <ando@openldap.org>
Mon, 21 Jun 2004 19:22:54 +0000 (19:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 21 Jun 2004 19:22:54 +0000 (19:22 +0000)
CHANGES
servers/slapd/controls.c

diff --git a/CHANGES b/CHANGES
index 3f3382043967684798b3929234af50e7fa78dbb1..2dba1f8977d3b1a1f5b93159abc084fd3a7ad674 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 OpenLDAP 2.2 Change Log
 
+OpenLDAP 2.2.15 Engineering
+       Fixed invalid cookie in pagedResults control (ITS#3089)
+
 OpenLDAP 2.2.14 Release
        Fixed back-bdb ignore deadlock bug (ITS#3188)
        Fixed back-bdb pagedResults no end cookie bug (ITS#3161)
index 302ec3b7268aea4d2f43bdbaf529fd37e6cac2e7..c43a95cbf36abfd8233a0d18693ce45192dab580 100644 (file)
@@ -844,10 +844,11 @@ static int parsePagedResults (
        SlapReply *rs,
        LDAPControl *ctrl )
 {
-       ber_tag_t tag;
-       ber_int_t size;
-       BerElement *ber;
-       struct berval cookie = BER_BVNULL;
+       int             rc = LDAP_SUCCESS;
+       ber_tag_t       tag;
+       ber_int_t       size;
+       BerElement      *ber;
+       struct berval   cookie = BER_BVNULL;
 
        if ( op->o_pagedresults != SLAP_NO_CONTROL ) {
                rs->sr_text = "paged results control specified multiple times";
@@ -879,16 +880,17 @@ static int parsePagedResults (
        }
 
        tag = ber_scanf( ber, "{im}", &size, &cookie );
-       (void) ber_free( ber, 1 );
 
        if( tag == LBER_ERROR ) {
                rs->sr_text = "paged results control could not be decoded";
-               return LDAP_PROTOCOL_ERROR;
+               rc = LDAP_PROTOCOL_ERROR;
+               goto done;
        }
 
        if( size < 0 ) {
                rs->sr_text = "paged results control size invalid";
-               return LDAP_PROTOCOL_ERROR;
+               rc = LDAP_PROTOCOL_ERROR;
+               goto done;
        }
 
        if( cookie.bv_len ) {
@@ -896,7 +898,8 @@ static int parsePagedResults (
                if( cookie.bv_len != sizeof( reqcookie ) ) {
                        /* bad cookie */
                        rs->sr_text = "paged results cookie is invalid";
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto done;
                }
 
                AC_MEMCPY( &reqcookie, cookie.bv_val, sizeof( reqcookie ));
@@ -904,11 +907,13 @@ static int parsePagedResults (
                if ( reqcookie > op->o_pagedresults_state.ps_cookie ) {
                        /* bad cookie */
                        rs->sr_text = "paged results cookie is invalid";
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto done;
 
                } else if ( reqcookie < op->o_pagedresults_state.ps_cookie ) {
                        rs->sr_text = "paged results cookie is invalid or old";
-                       return LDAP_UNWILLING_TO_PERFORM;
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
                }
 
        } else {
@@ -938,7 +943,9 @@ static int parsePagedResults (
                op->o_pagedresults = SLAP_NONCRITICAL_CONTROL;
        }
 
-       return LDAP_SUCCESS;
+done:;
+       (void)ber_free( ber, 1 );
+       return rc;
 }
 
 static int parseAssert (