]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/deref.c
Merge branch 'mdb.master' of ssh://git-master.openldap.org/~git/git/openldap
[openldap] / servers / slapd / overlays / deref.c
index c3d4e7d8ed7f06eb559c43b451e3bbe7346ecf41..8dbebf42a106211754964016e3459a83cd8c36f2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
  * Portions Copyright 2008 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -210,7 +210,7 @@ deref_parseCtrl (
                        }
                }
 
-               if ( ds->ds_derefAttr->ad_type->sat_syntax != slap_schema.si_syn_distinguishedName ) {
+               if ( !( ds->ds_derefAttr->ad_type->sat_syntax->ssyn_flags & SLAP_SYNTAX_DN )) {
                        if ( ctrl->ldctl_iscritical ) {
                                rs->sr_text = "Dereference control: derefAttr syntax not distinguishedName";
                                rs->sr_err = LDAP_PROTOCOL_ERROR;
@@ -290,7 +290,7 @@ deref_response( Operation *op, SlapReply *rs )
                struct berval bv = BER_BVNULL;
                int nDerefRes = 0, nDerefVals = 0, nAttrs = 0, nVals = 0;
                struct berval ctrlval;
-               LDAPControl *ctrl, **ctrlsp;
+               LDAPControl *ctrl, *ctrlsp[2];
                AccessControlState acl_state = ACL_STATE_INIT;
                static char dummy = '\0';
                Entry *ebase;
@@ -466,31 +466,14 @@ deref_response( Operation *op, SlapReply *rs )
                ctrl->ldctl_oid = LDAP_CONTROL_X_DEREF;
                ctrl->ldctl_iscritical = 0;
                ctrl->ldctl_value.bv_len = ctrlval.bv_len;
-               lutil_strncopy( ctrl->ldctl_value.bv_val, ctrlval.bv_val, ctrlval.bv_len );
+               AC_MEMCPY( ctrl->ldctl_value.bv_val, ctrlval.bv_val, ctrlval.bv_len );
                ctrl->ldctl_value.bv_val[ ctrl->ldctl_value.bv_len ] = '\0';
 
                ber_free_buf( ber );
 
-               i = 0;
-               if ( rs->sr_ctrls ) {
-                       for ( ; rs->sr_ctrls[ i ] != NULL; i++ )
-                               /* count'em */ ;
-               }
-               i += 2;
-               ctrlsp = op->o_tmpcalloc( i, sizeof(LDAPControl *), op->o_tmpmemctx );
-               i = 0;
-               if ( rs->sr_ctrls != NULL ) {
-                       for ( ; rs->sr_ctrls[ i ] != NULL; i++ ) {
-                               ctrlsp[ i ] = rs->sr_ctrls[ i ];
-                       }
-               }
-               ctrlsp[ i++ ] = ctrl;
-               ctrlsp[ i++ ] = NULL;
-               if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
-                       op->o_tmpfree( rs->sr_ctrls, op->o_tmpmemctx );
-               }
-               rs->sr_ctrls = ctrlsp;
-               rs->sr_flags |= REP_CTRLS_MUSTBEFREED;
+               ctrlsp[0] = ctrl;
+               ctrlsp[1] = NULL;
+               slap_add_ctrls( op, rs, ctrlsp );
 
                rc = SLAP_CB_CONTINUE;