]> git.sur5r.net Git - openldap/commitdiff
Update BER decoding of PDU to use "o" (struct berval) instead of
authorKurt Zeilenga <kurt@openldap.org>
Sat, 22 Dec 2001 21:52:58 +0000 (21:52 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 22 Dec 2001 21:52:58 +0000 (21:52 +0000)
"a" (char **)... another step towards BerValue DNs.

servers/slapd/add.c
servers/slapd/bind.c
servers/slapd/compare.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/search.c

index 28a545bcf845da6ffa1a7fe0beccbdba96bed20d..15018e1cb499eef038ff57035df4edd37dc1572d 100644 (file)
@@ -34,7 +34,8 @@ int
 do_add( Connection *conn, Operation *op )
 {
        BerElement      *ber = op->o_ber;
-       char            *dn, *last;
+       char            *last;
+       struct berval dn;
        ber_len_t       len;
        ber_tag_t       tag;
        Entry           *e;
@@ -65,7 +66,7 @@ do_add( Connection *conn, Operation *op )
         */
 
        /* get the name */
-       if ( ber_scanf( ber, "{a", /*}*/ &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( ber, "{o", /*}*/ &dn ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
                        "do_add: conn %d ber_scanf failed\n", conn->c_connid ));
@@ -79,17 +80,18 @@ do_add( Connection *conn, Operation *op )
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
 
-       e->e_dn = dn_pretty( dn );
-       e->e_ndn = dn_normalize( dn );
+       e->e_dn = dn_pretty( dn.bv_val );
+       e->e_ndn = dn_normalize( dn.bv_val );
        e->e_attrs = NULL;
        e->e_private = NULL;
 
        if ( e->e_ndn == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                       "do_add: conn %d         invalid dn (%s)\n", conn->c_connid, dn ));
+                       "do_add: conn %d         invalid dn (%s)\n", conn->c_connid,
+                       dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn.bv_val, 0, 0 );
 #endif
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
index b570908f03bfe02f0a64fd9f951fc89bebb9c129..6d2b83563e327dc683229dd193e4d1b6af0c0fc9 100644 (file)
@@ -37,7 +37,7 @@ do_bind(
        ber_int_t               version;
        ber_tag_t method;
        char            *mech;
-       char            *dn;
+       struct berval dn = { 0, NULL };
        char *ndn;
        ber_tag_t       tag;
        int                     rc = LDAP_SUCCESS;
@@ -46,12 +46,12 @@ do_bind(
        Backend         *be;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, "do_bind: conn %d\n", conn->c_connid ));
+       LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
+               "do_bind: conn %d\n", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
 #endif
 
-       dn = NULL;
        ndn = NULL;
        mech = NULL;
        cred.bv_val = NULL;
@@ -93,12 +93,12 @@ do_bind(
         *      }
         */
 
-       tag = ber_scanf( ber, "{iat" /*}*/, &version, &dn, &method );
+       tag = ber_scanf( ber, "{iot" /*}*/, &version, &dn, &method );
 
        if ( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_bind: conn %d  ber_scanf failed\n", conn->c_connid ));
+                       "do_bind: conn %d  ber_scanf failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -145,21 +145,23 @@ do_bind(
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_bind: conn %d  get_ctrls failed\n", conn->c_connid ));
+                       "do_bind: conn %d  get_ctrls failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 );
 #endif
                goto cleanup;
        } 
 
-       ndn = ch_strdup( dn );
+       ndn = ch_strdup( dn.bv_val );
 
        if ( dn_normalize( ndn ) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_bind: conn %d  invalid dn (%s)\n", conn->c_connid, dn ));
+                       "do_bind: conn %d  invalid dn (%s)\n",
+                       conn->c_connid, dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n",
+                       dn.bv_val, 0, 0 );
 #endif
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
@@ -169,20 +171,23 @@ do_bind(
        if( method == LDAP_AUTH_SASL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation",  LDAP_LEVEL_DETAIL1,
-                          "do_sasl_bind: conn %d  dn (%s) mech %s\n", conn->c_connid,
-                          dn, mech ));
+                       "do_sasl_bind: conn %d  dn (%s) mech %s\n", conn->c_connid,
+                       dn.bv_val, mech ));
 #else
                Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n",
-                       dn, mech, NULL );
+                       dn.bv_val, mech, NULL );
 #endif
        } else {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
-                          "do_bind: conn %d  version=%ld dn=\"%s\" method=%ld\n",
-                          conn->c_connid, (unsigned long) version, dn, (unsigned long)method ));
+                       "do_bind: conn %d  version=%ld dn=\"%s\" method=%ld\n",
+                       conn->c_connid, (unsigned long) version,
+                       dn.bv_val, (unsigned long)method ));
 #else
-               Debug( LDAP_DEBUG_TRACE, "do_bind: version=%ld dn=\"%s\" method=%ld\n",
-                       (unsigned long) version, dn, (unsigned long) method );
+               Debug( LDAP_DEBUG_TRACE,
+                       "do_bind: version=%ld dn=\"%s\" method=%ld\n",
+                       (unsigned long) version,
+                       dn.bv_val, (unsigned long) method );
 #endif
        }
 
@@ -192,8 +197,8 @@ do_bind(
        if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_bind: conn %d  unknown version = %ld\n",
-                          conn->c_connid, (unsigned long)version ));
+                       "do_bind: conn %d  unknown version = %ld\n",
+                       conn->c_connid, (unsigned long)version ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_bind: unknown version=%ld\n",
                        (unsigned long) version, 0, 0 );
@@ -224,8 +229,8 @@ do_bind(
                if ( version < LDAP_VERSION3 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                  "do_bind: conn %d  sasl with LDAPv%ld\n",
-                                  conn->c_connid, (unsigned long)version ));
+                               "do_bind: conn %d  sasl with LDAPv%ld\n",
+                               conn->c_connid, (unsigned long)version ));
 #else
                        Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n",
                                (unsigned long) version, 0, 0 );
@@ -272,7 +277,7 @@ do_bind(
                ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
 
                edn = NULL;
-               rc = slap_sasl_bind( conn, op, dn, ndn, &cred, &edn, &ssf );
+               rc = slap_sasl_bind( conn, op, dn.bv_val, ndn, &cred, &edn, &ssf );
 
                ldap_pvt_thread_mutex_lock( &conn->c_mutex );
                if( rc == LDAP_SUCCESS ) {
@@ -435,7 +440,7 @@ do_bind(
        if ( (be = select_backend( ndn, 0, 0 )) == NULL ) {
                if ( default_referral ) {
                        struct berval **ref = referral_rewrite( default_referral,
-                               NULL, dn, LDAP_SCOPE_DEFAULT );
+                               NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                                NULL, NULL, ref ? ref : default_referral, NULL );
@@ -469,14 +474,15 @@ do_bind(
                /* deref suffix alias if appropriate */
                ndn = suffix_alias( be, ndn );
 
-               ret = (*be->be_bind)( be, conn, op, dn, ndn,
+               ret = (*be->be_bind)( be, conn, op, dn.bv_val, ndn,
                        method, &cred, &edn );
 
                if ( ret == 0 ) {
                        ldap_pvt_thread_mutex_lock( &conn->c_mutex );
 
-                       conn->c_cdn = dn;
-                       dn = NULL;
+                       conn->c_cdn = dn.bv_val;
+                       dn.bv_val = NULL;
+                       dn.bv_len = 0;
 
                        if(edn != NULL) {
                                conn->c_dn = edn;
@@ -494,11 +500,11 @@ do_bind(
 
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
-                                  "do_bind: conn %d  v%d bind: \"%s\" to \"%s\" \n",
-                                  conn->c_connid, version, conn->c_cdn, conn->c_dn ));
+                               "do_bind: conn %d  v%d bind: \"%s\" to \"%s\" \n",
+                               conn->c_connid, version, conn->c_cdn, conn->c_dn ));
 #else
                        Debug( LDAP_DEBUG_TRACE, "do_bind: v%d bind: \"%s\" to \"%s\"\n",
-                       version, conn->c_cdn, conn->c_dn );
+                               version, conn->c_cdn, conn->c_dn );
 #endif
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
@@ -517,9 +523,7 @@ do_bind(
        }
 
 cleanup:
-       if( dn != NULL ) {
-               free( dn );
-       }
+       free( dn.bv_val );
        if( ndn != NULL ) {
                free( ndn );
        }
index b3ccf30a71681b40003b7c0fe73caf1bd753951d..e751f4fb1fcb5cc2115057c27c972995b75b62ca 100644 (file)
@@ -36,7 +36,8 @@ do_compare(
 )
 {
        Entry *entry = NULL;
-       char    *dn = NULL, *ndn=NULL;
+       struct berval dn = { 0, NULL };
+       char *ndn = NULL;
        struct berval desc;
        struct berval value;
        struct berval *nvalue;
@@ -52,7 +53,7 @@ do_compare(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-                  "do_compare: conn %d\n", conn->c_connid ));
+               "do_compare: conn %d\n", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
 #endif
@@ -68,10 +69,10 @@ do_compare(
         *      }
         */
 
-       if ( ber_scanf( op->o_ber, "{a" /*}*/, &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( op->o_ber, "{o" /*}*/, &dn ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_compare: conn %d  ber_scanf failed\n", conn->c_connid ));
+                       "do_compare: conn %d  ber_scanf failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -83,7 +84,7 @@ do_compare(
        if ( ber_scanf( op->o_ber, "{oo}", &desc, &value ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_compare: conn %d  get ava failed\n", conn->c_connid ));
+                       "do_compare: conn %d  get ava failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_compare: get ava failed\n", 0, 0, 0 );
 #endif
@@ -96,7 +97,7 @@ do_compare(
        if ( ber_scanf( op->o_ber, /*{*/ "}" ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_compare: conn %d  ber_scanf failed\n", conn->c_connid ));
+                       "do_compare: conn %d  ber_scanf failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -109,22 +110,23 @@ do_compare(
        if( ( rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_compare: conn %d  get_ctrls failed\n", conn->c_connid ));
+                       "do_compare: conn %d  get_ctrls failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 );
 #endif
                goto cleanup;
        } 
 
-       ndn = ch_strdup( dn );
+       ndn = ch_strdup( dn.bv_val );
 
        if( dn_normalize( ndn ) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_compare: conn %d  invalid dn (%s)\n",
-                          conn->c_connid, dn ));
+                       "do_compare: conn %d  invalid dn (%s)\n",
+                       conn->c_connid, dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_compare: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY,
+                       "do_compare: invalid dn (%s)\n", dn.bv_val, 0, 0 );
 #endif
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
@@ -149,16 +151,17 @@ do_compare(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                        "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                       conn->c_connid, dn, ava.aa_desc->ad_cname.bv_val,
+                       conn->c_connid, dn.bv_val, ava.aa_desc->ad_cname.bv_val,
                        ava.aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-                       dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+                       dn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
                Statslog( LDAP_DEBUG_STATS,
                        "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-                       op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname.bv_val, 0 );
+                       op->o_connid, op->o_opid, dn.bv_val,
+                       ava.aa_desc->ad_cname.bv_val, 0 );
 
                rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
                if( rc != LDAP_SUCCESS ) {
@@ -176,16 +179,17 @@ do_compare(
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
                        "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                       conn->c_connid, dn, ava.aa_desc->ad_cname.bv_val,
+                       conn->c_connid, dn.bv_val, ava.aa_desc->ad_cname.bv_val,
                        ava.aa_value->bv_val ));
 #else
                Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-                       dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+                       dn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
                Statslog( LDAP_DEBUG_STATS,
                        "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
-                       op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname.bv_val, 0 );
+                       op->o_connid, op->o_opid, dn.bv_val,
+                       ava.aa_desc->ad_cname.bv_val, 0 );
 
                rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
                if( rc != LDAP_SUCCESS ) {
@@ -224,7 +228,7 @@ do_compare(
         */
        if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, dn, LDAP_SCOPE_DEFAULT );
+                       NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -243,19 +247,19 @@ do_compare(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, dn, ndn );
+       rc = backend_check_referrals( be, conn, op, dn.bv_val, ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_compare: conn %d  dn (%s) attr(%s) value (%s)\n",
-                  conn->c_connid, dn, ava.aa_desc->ad_cname.bv_val,
-                  ava.aa_value->bv_val ));
+               "do_compare: conn %d     dn (%s) attr(%s) value (%s)\n",
+               conn->c_connid, dn.bv_val, ava.aa_desc->ad_cname.bv_val,
+               ava.aa_value->bv_val ));
 #else
        Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
-           dn, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
+           dn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val );
 #endif
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
@@ -266,14 +270,14 @@ do_compare(
        ndn = suffix_alias( be, ndn );
 
        if ( be->be_compare ) {
-               (*be->be_compare)( be, conn, op, dn, ndn, &ava );
+               (*be->be_compare)( be, conn, op, dn.bv_val, ndn, &ava );
        } else {
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "operation not supported within namingContext", NULL, NULL );
        }
 
 cleanup:
-       free( dn );
+       free( dn.bv_val );
        free( ndn );
        free( desc.bv_val );
        free( value.bv_val );
index 27a68d529d97fd50c25c166942f190d19a30b6b1..3eb3c2c7b58443e2a761ec338af6839003b710e7 100644 (file)
@@ -31,7 +31,8 @@ do_delete(
     Operation  *op
 )
 {
-       char *dn, *ndn = NULL;
+       struct berval dn = { 0, NULL };
+       char *ndn = NULL;
        const char *text;
        Backend *be;
        int rc;
@@ -39,7 +40,7 @@ do_delete(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-                  "do_delete: conn %d\n", conn->c_connid ));
+               "do_delete: conn %d\n", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
 #endif
@@ -50,10 +51,10 @@ do_delete(
         *      DelRequest := DistinguishedName
         */
 
-       if ( ber_scanf( op->o_ber, "a", &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( op->o_ber, "o", &dn ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_delete: conn: %d  ber_scanf failed\n", conn->c_connid ));
+                       "do_delete: conn: %d  ber_scanf failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -65,21 +66,23 @@ do_delete(
        if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "oepration", LDAP_LEVEL_ERR,
-                          "do_delete: conn %d  get_ctrls failed\n", conn->c_connid ));
+                       "do_delete: conn %d  get_ctrls failed\n", conn->c_connid ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_delete: get_ctrls failed\n", 0, 0, 0 );
 #endif
                goto cleanup;
        } 
 
-       ndn = ch_strdup( dn );
+       ndn = ch_strdup( dn.bv_val );
 
        if(     dn_normalize( ndn ) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_delete: conn %d  invalid dn (%s).\n", conn->c_connid, dn ));
+                       "do_delete: conn %d  invalid dn (%s).\n",
+                       conn->c_connid, dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n",
+                       dn.bv_val, 0, 0 );
 #endif
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
@@ -115,7 +118,7 @@ do_delete(
        }
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d DEL dn=\"%s\"\n",
-               op->o_connid, op->o_opid, dn, 0, 0 );
+               op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -126,7 +129,7 @@ do_delete(
         */
        if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, dn, LDAP_SCOPE_DEFAULT );
+                       NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -144,7 +147,7 @@ do_delete(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, dn, ndn );
+       rc = backend_check_referrals( be, conn, op, dn.bv_val, ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
@@ -165,12 +168,12 @@ do_delete(
                if ( be->be_update_ndn == NULL || repl_user )
 #endif
                {
-                       if ( (*be->be_delete)( be, conn, op, dn, ndn ) == 0 ) {
+                       if ( (*be->be_delete)( be, conn, op, dn.bv_val, ndn ) == 0 ) {
 #ifdef SLAPD_MULTIMASTER
                                if (be->be_update_ndn == NULL || !repl_user )
 #endif
                                {
-                                       replog( be, op, dn, ndn, NULL );
+                                       replog( be, op, dn.bv_val, ndn, NULL );
                                }
                        }
 #ifndef SLAPD_MULTIMASTER
@@ -178,7 +181,7 @@ do_delete(
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( default_referral,
-                               NULL, dn, LDAP_SCOPE_DEFAULT );
+                               NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -191,8 +194,9 @@ do_delete(
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "operation not supported within namingContext", NULL, NULL );
        }
+
 cleanup:
        if( ndn != NULL ) free( ndn );
-       free( dn );
+       free( dn.bv_val );
        return rc;
 }
index a04ba300121faa0d9ed8515e762c3a6da29415d1..2b9625857ac3c70c35e90dc0b6d7b5fa53de5d55 100644 (file)
@@ -33,7 +33,8 @@ do_modify(
     Connection *conn,
     Operation  *op )
 {
-       char            *dn, *ndn = NULL;
+       struct berval dn = { 0, NULL };
+       char *ndn = NULL;
        char            *last;
        ber_tag_t       tag;
        ber_len_t       len;
@@ -50,7 +51,7 @@ do_modify(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-                  "do_modify: enter\n" ));
+               "do_modify: enter\n" ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
 #endif
@@ -74,10 +75,10 @@ do_modify(
         *      }
         */
 
-       if ( ber_scanf( op->o_ber, "{a" /*}*/, &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( op->o_ber, "{o" /*}*/, &dn ) == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modify: ber_scanf failed\n" ));
+                       "do_modify: ber_scanf failed\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -89,9 +90,9 @@ do_modify(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_modify: dn (%s)\n", dn ));
+                  "do_modify: dn (%s)\n", dn.bv_val ));
 #else
-       Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn, 0, 0 );
+       Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
 #endif
 
 
@@ -120,8 +121,8 @@ do_modify(
                        if ( (*modtail)->ml_bvalues == NULL ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                          "do_modify: modify/add operation (%ld) requires values\n",
-                                          (long)mop ));
+                                       "do_modify: modify/add operation (%ld) requires values\n",
+                                       (long)mop ));
 #else
                                Debug( LDAP_DEBUG_ANY,
                                        "do_modify: modify/add operation (%ld) requires values\n",
@@ -144,8 +145,8 @@ do_modify(
                default: {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                          "do_modify: invalid modify operation (%ld)\n",
-                                          (long)mop ));
+                                       "do_modify: invalid modify operation (%ld)\n",
+                                       (long)mop ));
 #else
                                Debug( LDAP_DEBUG_ANY,
                                        "do_modify: invalid modify operation (%ld)\n",
@@ -167,7 +168,7 @@ do_modify(
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modify: get_ctrls failed\n" ));
+                       "do_modify: get_ctrls failed\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
 #endif
@@ -175,14 +176,16 @@ do_modify(
                goto cleanup;
        }
 
-       ndn = ch_strdup( dn );
+       ndn = ch_strdup( dn.bv_val );
 
        if(     dn_normalize( ndn ) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modify:  invalid dn (%s)\n", dn ));
+                       "do_modify: invalid dn (%s)\n", dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY,
+                       "do_modify: invalid dn (%s)\n",
+                       dn.bv_val, 0, 0 );
 #endif
 
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
@@ -193,7 +196,7 @@ do_modify(
        if( *ndn == '\0' ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modify: attempt to modify root DSE.\n" ));
+                       "do_modify: attempt to modify root DSE.\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
 #endif
@@ -229,9 +232,9 @@ do_modify(
        for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
-                          "\t%s:  %s\n", tmp->ml_op == LDAP_MOD_ADD ?
-                          "add" : (tmp->ml_op == LDAP_MOD_DELETE ?
-                                   "delete" : "replace"), tmp->ml_type ));
+                       "\t%s:  %s\n", tmp->ml_op == LDAP_MOD_ADD ?
+                               "add" : (tmp->ml_op == LDAP_MOD_DELETE ?
+                                       "delete" : "replace"), tmp->ml_type ));
 
                if ( tmp->ml_bvalues == NULL ) {
                        LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
@@ -271,7 +274,7 @@ do_modify(
 #endif
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
-           op->o_connid, op->o_opid, dn, 0, 0 );
+           op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -282,7 +285,7 @@ do_modify(
         */
        if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, dn, LDAP_SCOPE_DEFAULT );
+                       NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -300,7 +303,7 @@ do_modify(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, dn, ndn );
+       rc = backend_check_referrals( be, conn, op, dn.bv_val, ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
@@ -359,13 +362,13 @@ do_modify(
                                }
                        }
 
-                       if ( (*be->be_modify)( be, conn, op, dn, ndn, mods ) == 0 
+                       if ( (*be->be_modify)( be, conn, op, dn.bv_val, ndn, mods ) == 0
 #ifdef SLAPD_MULTIMASTER
                                && !repl_user
 #endif
                        ) {
                                /* but we log only the ones not from a replicator user */
-                               replog( be, op, dn, ndn, mods );
+                               replog( be, op, dn.bv_val, ndn, mods );
                        }
 
 #ifndef SLAPD_MULTIMASTER
@@ -374,7 +377,7 @@ do_modify(
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( defref,
-                               NULL, dn, LDAP_SCOPE_DEFAULT );
+                               NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -388,7 +391,7 @@ do_modify(
        }
 
 cleanup:
-       free( dn );
+       free( dn.bv_val );
        if( ndn != NULL ) free( ndn );
        if ( modlist != NULL )
                slap_modlist_free( modlist );
index 1914d8e013a737b0fb78c0c664ce622969c391db..c3247c26cae0f69b219d73bfe6c9f5bab3a0715f 100644 (file)
@@ -44,12 +44,15 @@ do_modrdn(
     Operation  *op
 )
 {
-       char    *dn, *ndn = NULL, *newrdn;
+       struct berval dn = { 0, NULL };
+       struct berval newrdn = { 0, NULL };
+       struct berval newSuperior = { 0, NULL };
        ber_int_t       deloldrdn;
-       Backend *be;
-       /* Vars for LDAP v3 newSuperior support */
-       char    *newSuperior = NULL;
+
+       char    *ndn = NULL;
        char    *nnewSuperior = NULL;
+
+       Backend *be;
        Backend *newSuperior_be = NULL;
        ber_len_t       length;
        int rc;
@@ -58,7 +61,7 @@ do_modrdn(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-                  "do_modrdn: begin\n" ));
+               "do_modrdn: begin\n" ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
 #endif
@@ -75,11 +78,12 @@ do_modrdn(
         *      }
         */
 
-       if ( ber_scanf( op->o_ber, "{aab", &dn, &newrdn, &deloldrdn )
-           == LBER_ERROR ) {
+       if ( ber_scanf( op->o_ber, "{oob", &dn, &newrdn, &deloldrdn )
+           == LBER_ERROR )
+       {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modrdn: ber_scanf failed\n" ));
+                       "do_modrdn: ber_scanf failed\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
 #endif
@@ -98,11 +102,11 @@ do_modrdn(
                         */
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                  "do_modrdn: (v2) invalid field newSuperior.\n" ));
+                               "do_modrdn: (v2) invalid field newSuperior.\n" ));
 #else
                        Debug( LDAP_DEBUG_ANY,
-                              "modrdn(v2): invalid field newSuperior!\n",
-                              0, 0, 0 );
+                           "modrdn(v2): invalid field newSuperior!\n",
+                           0, 0, 0 );
 #endif
 
                        send_ldap_disconnect( conn, op,
@@ -111,15 +115,15 @@ do_modrdn(
                        goto cleanup;
                }
 
-               if ( ber_scanf( op->o_ber, "a", &newSuperior ) 
+               if ( ber_scanf( op->o_ber, "o", &newSuperior ) 
                     == LBER_ERROR ) {
 
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                  "do_modrdn: ber_scanf(\"a\") failed\n" ));
+                               "do_modrdn: ber_scanf(\"a\") failed\n" ));
 #else
                        Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\") failed\n",
-                          0, 0, 0 );
+                               0, 0, 0 );
 #endif
 
                        send_ldap_disconnect( conn, op,
@@ -128,15 +132,16 @@ do_modrdn(
                        goto cleanup;
                }
 
-               nnewSuperior = ch_strdup( newSuperior );
+               nnewSuperior = ch_strdup( newSuperior.bv_val );
 
                if( dn_normalize( nnewSuperior ) == NULL ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                  "do_modrdn:  invalid new superior (%s)\n", newSuperior ));
+                               "do_modrdn:  invalid new superior (%s)\n",
+                               newSuperior.bv_val ));
 #else
                        Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid new superior (%s)\n",
-                               newSuperior, 0, 0 );
+                               newSuperior.bv_val, 0, 0 );
 #endif
 
                        send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
@@ -148,26 +153,27 @@ do_modrdn(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_modrdn: dn (%s) newrdn (%s) newsuperior(%s)\n",
-                  dn, newrdn, newSuperior != NULL ? newSuperior : "" ));
+               "do_modrdn: dn (%s) newrdn (%s) newsuperior(%s)\n",
+               dn.bv_val, newrdn.bv_val,
+               newSuperior.bv_len ? newSuperior.bv_val : "" ));
 #else
        Debug( LDAP_DEBUG_ARGS,
            "do_modrdn: dn (%s) newrdn (%s) newsuperior (%s)\n",
-               dn, newrdn,
-               newSuperior != NULL ? newSuperior : "" );
+               dn.bv_val, newrdn.bv_val,
+               newSuperior.bv_len ? newSuperior.bv_val : "" );
 #endif
 
 
        if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modrdn: ber_scanf failed\n" ));
+                       "do_modrdn: ber_scanf failed\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
 #endif
 
                send_ldap_disconnect( conn, op,
-                               LDAP_PROTOCOL_ERROR, "decoding error" );
+                       LDAP_PROTOCOL_ERROR, "decoding error" );
                rc = SLAPD_DISCONNECT;
                goto cleanup;
        }
@@ -175,7 +181,7 @@ do_modrdn(
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modrdn: get_ctrls failed\n" ));
+                       "do_modrdn: get_ctrls failed\n" ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
 #endif
@@ -184,14 +190,15 @@ do_modrdn(
                goto cleanup;
        } 
 
-       ndn = ch_strdup( dn );
+       ndn = ch_strdup( dn.bv_val );
 
        if( dn_normalize( ndn ) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modrdn: invalid dn (%s)\n", dn ));
+                       "do_modrdn: invalid dn (%s)\n", dn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n", dn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n",
+                       dn.bv_val, 0, 0 );
 #endif
 
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
@@ -199,12 +206,13 @@ do_modrdn(
                goto cleanup;
        }
 
-       if( !rdn_validate( newrdn ) ) {
+       if( !rdn_validate( newrdn.bv_val ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                          "do_modrdn: invalid rdn (%s).\n", newrdn ));
+                       "do_modrdn: invalid rdn (%s).\n", newrdn.bv_val ));
 #else
-               Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n", newrdn, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n",
+                       newrdn.bv_val, 0, 0 );
 #endif
 
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
@@ -240,7 +248,7 @@ do_modrdn(
        }
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MODRDN dn=\"%s\"\n",
-           op->o_connid, op->o_opid, dn, 0, 0 );
+           op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -251,7 +259,7 @@ do_modrdn(
         */
        if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, dn, LDAP_SCOPE_DEFAULT );
+                       NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -269,7 +277,7 @@ do_modrdn(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, dn, ndn );
+       rc = backend_check_referrals( be, conn, op, dn.bv_val, ndn );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
@@ -277,7 +285,7 @@ do_modrdn(
        /* Make sure that the entry being changed and the newSuperior are in 
         * the same backend, otherwise we return an error.
         */
-       if( newSuperior != NULL ) {
+       if( newSuperior.bv_len ) {
                newSuperior_be = select_backend( nnewSuperior, 0, 0 );
 
                if ( newSuperior_be != be ) {
@@ -310,25 +318,25 @@ do_modrdn(
                if ( be->be_update_ndn == NULL || repl_user )
 #endif
                {
-                       if ( (*be->be_modrdn)( be, conn, op, dn, ndn, newrdn,
-                           deloldrdn, newSuperior ) == 0
+                       if ( (*be->be_modrdn)( be, conn, op, dn.bv_val, ndn,
+                               newrdn.bv_val, deloldrdn, newSuperior.bv_val ) == 0
 #ifdef SLAPD_MULTIMASTER
                                && ( be->be_update_ndn == NULL || !repl_user )
 #endif
                        ) {
                                struct replog_moddn moddn;
-                               moddn.newrdn = newrdn;
+                               moddn.newrdn = newrdn.bv_val;
                                moddn.deloldrdn = deloldrdn;
-                               moddn.newsup = newSuperior;
+                               moddn.newsup = newSuperior.bv_val;
 
-                               replog( be, op, dn, ndn, &moddn );
+                               replog( be, op, dn.bv_val, ndn, &moddn );
                        }
 #ifndef SLAPD_MULTIMASTER
                } else {
                        struct berval **defref = be->be_update_refs
                                ? be->be_update_refs : default_referral;
                        struct berval **ref = referral_rewrite( defref,
-                               NULL, dn, LDAP_SCOPE_DEFAULT );
+                               NULL, dn.bv_val, LDAP_SCOPE_DEFAULT );
 
                        send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
                                ref ? ref : defref, NULL );
@@ -338,16 +346,16 @@ do_modrdn(
                }
        } else {
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
-                       NULL, "operation not supported within namingContext", NULL, NULL );
+                       NULL, "operation not supported within namingContext",
+                       NULL, NULL );
        }
 
 cleanup:
-       free( dn );
+       free( dn.bv_val );
+       free( newrdn.bv_val );  
+       free( newSuperior.bv_val );
+
        if( ndn != NULL ) free( ndn );
-       free( newrdn ); 
-       if ( newSuperior != NULL )
-               free( newSuperior );
-       if ( nnewSuperior != NULL )
-               free( nnewSuperior );
+       if ( nnewSuperior != NULL ) free( nnewSuperior );
        return rc;
 }
index 08402dc8a79a094cf5eced2a04f3000502ec7f2a..197126f6a107ffec7c4be89ba8aac075db462bad 100644 (file)
@@ -31,19 +31,20 @@ do_search(
     Operation  *op     /* info about the op to which we're responding */
 ) {
        int             i;
-       ber_int_t               scope, deref, attrsonly;
-       ber_int_t               sizelimit, timelimit;
-       char            *base = NULL, *nbase = NULL, *fstr = NULL;
+       ber_int_t       scope, deref, attrsonly;
+       ber_int_t       sizelimit, timelimit;
+       struct berval base = { 0, NULL };
+       char            *nbase = NULL, *fstr = NULL;
        Filter          *filter = NULL;
        char            **attrs = NULL;
        Backend         *be;
        int                     rc;
-       const char              *text;
+       const char      *text;
        int                     manageDSAit;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
-                  "do_search: conn %d\n", conn->c_connid ));
+               "do_search: conn %d\n", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
 #endif
@@ -73,9 +74,10 @@ do_search(
         */
 
        /* baseObject, scope, derefAliases, sizelimit, timelimit, attrsOnly */
-       if ( ber_scanf( op->o_ber, "{aiiiib" /*}*/,
+       if ( ber_scanf( op->o_ber, "{oiiiib" /*}*/,
                &base, &scope, &deref, &sizelimit,
-           &timelimit, &attrsonly ) == LBER_ERROR ) {
+           &timelimit, &attrsonly ) == LBER_ERROR )
+       {
                send_ldap_disconnect( conn, op,
                        LDAP_PROTOCOL_ERROR, "decoding error" );
                rc = SLAPD_DISCONNECT;
@@ -105,7 +107,7 @@ do_search(
                goto return_results;
        }
 
-       nbase = ch_strdup( base );
+       nbase = ch_strdup( base.bv_val );
 
        if( dn_normalize( nbase ) == NULL ) {
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
@@ -115,10 +117,10 @@ do_search(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_search \"%s\" %d %d %d %d %d\n", base, scope,
-                  deref, sizelimit, timelimit, attrsonly ));
+               "do_search \"%s\" %d %d %d %d %d\n", base.bv_val, scope,
+               deref, sizelimit, timelimit, attrsonly ));
 #else
-       Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d", base, scope, deref );
+       Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d", base.bv_val, scope, deref );
        Debug( LDAP_DEBUG_ARGS, "    %d %d %d\n", sizelimit, timelimit,
            attrsonly);
 #endif
@@ -138,7 +140,7 @@ do_search(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_search: conn %d  filter: %s\n", conn->c_connid, fstr ));
+               "do_search: conn %d     filter: %s\n", conn->c_connid, fstr ));
 #else
        Debug( LDAP_DEBUG_ARGS, "    filter: %s\n", fstr, 0, 0 );
 #endif
@@ -155,8 +157,8 @@ do_search(
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                          "do_search: conn %d  get_ctrls failed (%d)\n",
-                          conn->c_connid, rc ));
+                       "do_search: conn %d  get_ctrls failed (%d)\n",
+                       conn->c_connid, rc ));
 #else
                Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 );
 #endif
@@ -168,7 +170,7 @@ do_search(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                  "do_search: conn %d  attrs:", conn->c_connid ));
+               "do_search: conn %d     attrs:", conn->c_connid ));
 #else
        Debug( LDAP_DEBUG_ARGS, "    attrs:", 0, 0, 0 );
 #endif
@@ -178,7 +180,7 @@ do_search(
                for ( i = 0; attrs[i] != NULL; i++ ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
-                                  "do_search:     %s", attrs[i] ));
+                               "do_search:        %s", attrs[i] ));
 #else
                        Debug( LDAP_DEBUG_ARGS, " %s", attrs[i], 0, 0 );
 #endif
@@ -194,7 +196,7 @@ do_search(
 
        Statslog( LDAP_DEBUG_STATS,
            "conn=%ld op=%d SRCH base=\"%s\" scope=%d filter=\"%s\"\n",
-           op->o_connid, op->o_opid, base, scope, fstr );
+           op->o_connid, op->o_opid, base.bv_val, scope, fstr );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -256,9 +258,10 @@ do_search(
        }
 
        if( nbase[0] == '\0' && default_search_nbase != NULL ) {
-               ch_free( base );
+               ch_free( base.bv_val );
                ch_free( nbase );
-               base = ch_strdup( default_search_base );
+               base.bv_val = ch_strdup( default_search_base );
+               base.bv_len = strlen( default_search_nbase );
                nbase = ch_strdup( default_search_nbase );
        }
 
@@ -269,7 +272,7 @@ do_search(
         */
        if ( (be = select_backend( nbase, manageDSAit, 1 )) == NULL ) {
                struct berval **ref = referral_rewrite( default_referral,
-                       NULL, base, scope );
+                       NULL, base.bv_val, scope );
 
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, ref ? ref : default_referral, NULL );
@@ -287,7 +290,7 @@ do_search(
        }
 
        /* check for referrals */
-       rc = backend_check_referrals( be, conn, op, base, nbase );
+       rc = backend_check_referrals( be, conn, op, base.bv_val, nbase );
        if ( rc != LDAP_SUCCESS ) {
                goto return_results;
        }
@@ -297,7 +300,8 @@ do_search(
 
        /* actually do the search and send the result(s) */
        if ( be->be_search ) {
-               (*be->be_search)( be, conn, op, base, nbase, scope, deref, sizelimit,
+               (*be->be_search)( be, conn, op, base.bv_val, nbase,
+                       scope, deref, sizelimit,
                    timelimit, filter, fstr, attrs, attrsonly );
        } else {
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
@@ -305,7 +309,7 @@ do_search(
        }
 
 return_results:;
-       if( base != NULL) free( base );
+       free( base.bv_val );
        if( nbase != NULL) free( nbase );
        if( fstr != NULL) free( fstr );
        if( filter != NULL) filter_free( filter );