]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
Plug mutex/rwlock leaks (destroy them)
[openldap] / servers / slapd / controls.c
index d20dbd30ae3c31c44cb2221da59ebbf7bd57f0cb..8467ff8536ddf8fb821bc1e2b16798ecf69c04f4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1137,14 +1137,13 @@ static int parseProxyAuthz (
        }
 
        ch_free( op->o_ndn.bv_val );
-       ch_free( op->o_dn.bv_val );
 
        /*
         * NOTE: since slap_sasl_getdn() returns a normalized dn,
         * from now on op->o_dn is normalized
         */
        op->o_ndn = dn;
-       ber_dupbv( &op->o_dn, &dn );
+       ber_bvreplace( &op->o_dn, &dn );
 
        Statslog( LDAP_DEBUG_STATS, "%s PROXYAUTHZ dn=\"%s\"\n",
            op->o_log_prefix, dn.bv_val, 0, 0, 0 );
@@ -1234,6 +1233,8 @@ static int parsePagedResults (
        if ( !cookie.bv_len ) {
                ps->ps_count = 0;
                ps->ps_cookie = 0;
+               /* taint ps_cookie, to detect whether it's set */
+               op->o_conn->c_pagedresults_state.ps_cookie = NOID;
        }
 
        /* NOTE: according to RFC 2696 3.:
@@ -1671,6 +1672,24 @@ static int parseSearchOptions (
                return LDAP_PROTOCOL_ERROR;
        }
 
+       if ( search_flags & ~(LDAP_SEARCH_FLAG_DOMAIN_SCOPE) ) {
+               /* Search flags not recognised so far,
+                * including:
+                *              LDAP_SEARCH_FLAG_PHANTOM_ROOT
+                */
+               if ( ctrl->ldctl_iscritical ) {
+                       rs->sr_text = "searchOptions contained unrecognized flag";
+                       return LDAP_UNWILLING_TO_PERFORM;
+               }
+
+               /* Ignore */
+               Debug( LDAP_DEBUG_TRACE,
+                       "searchOptions: conn=%lu unrecognized flag(s) 0x%x (non-critical)\n", 
+                       op->o_connid, (unsigned)search_flags, 0 );
+
+               return LDAP_SUCCESS;
+       }
+
        if ( search_flags & LDAP_SEARCH_FLAG_DOMAIN_SCOPE ) {
                if ( op->o_domain_scope != SLAP_CONTROL_NONE ) {
                        rs->sr_text = "searchOptions control specified multiple times "
@@ -1683,15 +1702,6 @@ static int parseSearchOptions (
                        : SLAP_CONTROL_NONCRITICAL;
        }
 
-       if ( search_flags & ~(LDAP_SEARCH_FLAG_DOMAIN_SCOPE) ) {
-               /* Other search flags not recognised so far,
-                * including:
-                *              LDAP_SEARCH_FLAG_PHANTOM_ROOM
-                */
-               rs->sr_text = "searchOptions contained unrecognized flag";
-               return LDAP_UNWILLING_TO_PERFORM;
-       }
-
        return LDAP_SUCCESS;
 }