]> git.sur5r.net Git - openldap/commitdiff
Fix previous dn checkin
authorHoward Chu <hyc@openldap.org>
Sun, 19 Sep 1999 01:29:45 +0000 (01:29 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 19 Sep 1999 01:29:45 +0000 (01:29 +0000)
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 a285c0328b301c691668b989e210b27235a15421..e02108e00aab0502ffa7144334dce5cb7284348d 100644 (file)
@@ -109,16 +109,15 @@ do_bind(
                goto cleanup;
        }
 
-       if ( dn_normalize( dn ) == NULL ) {
+       ndn = ch_strdup( dn );
+
+       if ( dn_normalize_case( ndn ) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
                goto cleanup;
        }
 
-       ndn = ch_strdup( dn );
-       ldap_pvt_str2upper( ndn );
-
        op->o_protocol = version;
 
        if( method != LDAP_AUTH_SASL ) {
index 0ad02a5b9feb736015ac7804de3b24e2068abbe6..8e1338dc92b25e6aa67785293830cec17088755f 100644 (file)
@@ -29,7 +29,7 @@ do_compare(
     Operation  *op
 )
 {
-       char    *dn, *ndn;
+       char    *dn = NULL, *ndn=NULL;
        Ava     ava;
        Backend *be;
        int rc = LDAP_SUCCESS;
@@ -64,20 +64,19 @@ do_compare(
                return -1;
        }
 
-       if( dn_normalize( dn ) == NULL ) {
+       ndn = ch_strdup( dn );
+
+
+       if( dn_normalize_case( ndn ) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "do_compare: invalid dn (%s)\n", dn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
-               free( dn );
-               ava_free( &ava, 0 );
-               return rc;
+               goto cleanup;
        }
 
        if( ( rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
-               free( dn );
-               ava_free( &ava, 0 );
                Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 );
-               return rc;
+               goto cleanup;
        } 
 
        value_normalize( ava.ava_value.bv_val, attr_syntax( ava.ava_type ) );
@@ -88,22 +87,16 @@ do_compare(
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
            op->o_connid, op->o_opid, dn, ava.ava_type, 0 );
 
-       ndn = ch_strdup( dn );
-       ldap_pvt_str2upper( ndn );
-
        /*
         * We could be serving multiple database backends.  Select the
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
        if ( (be = select_backend( ndn )) == NULL ) {
-               free( dn );
-               free( ndn );
-               ava_free( &ava, 0 );
-
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, default_referral, NULL );
-               return 1;
+               rc = 1;
+               goto cleanup;
        }
 
        /* deref suffix alias if appropriate */
@@ -115,7 +108,7 @@ do_compare(
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "Function not implemented", NULL, NULL );
        }
-
+cleanup:
        free( dn );
        free( ndn );
        ava_free( &ava, 0 );
index 235a425c0c953c154d1c4dafde4233cfce13749d..ae27648ab5ed73697005a4f4fdf95677b8d4a250 100644 (file)
@@ -57,26 +57,23 @@ do_delete(
                return -1;
        }
 
-       if(     dn_normalize( dn ) == NULL ) {
+       ndn = ch_strdup( dn );
+
+       if(     dn_normalize_case( ndn ) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", dn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
-               free( dn );
-               return rc;
+               goto cleanup;
        }
 
        if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) {
-               free( dn );
                Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
-               return rc;
+               goto cleanup;
        } 
 
        Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", dn, 0, 0 );
        Debug( LDAP_DEBUG_STATS, "DEL dn=\"%s\"\n", dn, 0, 0 );
 
-       ndn = ch_strdup( dn );
-       ldap_pvt_str2upper( ndn );
-
        /*
         * We could be serving multiple database backends.  Select the
         * appropriate one, or send a referral to our "referral server"
@@ -85,19 +82,16 @@ do_delete(
        if ( (be = select_backend( ndn )) == NULL ) {
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, default_referral, NULL );
-               free( dn );
-               free( ndn );
-               return rc;
+               goto cleanup;
        }
 
        if ( global_readonly || be->be_readonly ) {
                Debug( LDAP_DEBUG_ANY, "do_delete: database is read-only\n",
                       0, 0, 0 );
-               free( dn );
-               free( ndn );
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                  NULL, "database is read-only", NULL, NULL );
-               return LDAP_UNWILLING_TO_PERFORM;
+               rc = LDAP_UNWILLING_TO_PERFORM;
+               goto cleanup;
        }
 
        /* deref suffix alias if appropriate */
@@ -136,8 +130,8 @@ do_delete(
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "Function not implemented", NULL, NULL );
        }
-
-       free( dn );
+cleanup:
        free( ndn );
+       free( dn );
        return rc;
 }
index 7a61fc1cd63a146dd92a44bbb76090e9cba45cb4..187bcc443fba6a204d5b13bc21255317c20ab010 100644 (file)
@@ -39,8 +39,8 @@ do_modify(
        char            *last;
        ber_tag_t       tag;
        ber_len_t       len;
-       LDAPModList     *modlist;
-       LDAPModList     **modtail;
+       LDAPModList     *modlist = NULL;
+       LDAPModList     **modtail = &modlist;
 #ifdef LDAP_DEBUG
        LDAPModList *tmp;
 #endif
@@ -85,17 +85,16 @@ do_modify(
 
        Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn, 0, 0 );
 
-       if(     dn_normalize( dn ) == NULL ) {
+       ndn = ch_strdup( ndn );
+
+       if(     dn_normalize( ndn ) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
-               free( dn );
-               return rc;
+               goto cleanup;
        }
 
        /* collect modifications & save for later */
-       modlist = NULL;
-       modtail = &modlist;
 
        for ( tag = ber_first_element( op->o_ber, &len, &last );
            tag != LBER_DEFAULT;
@@ -111,11 +110,8 @@ do_modify(
                {
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "decoding modlist error" );
-                       free( dn );
-                       free( *modtail );
-                       *modtail = NULL;
-                       modlist_free( modlist );
-                       return -1;
+                       rc = -1;
+                       goto cleanup;
                }
 
                (*modtail)->ml_op = mop;
@@ -129,9 +125,8 @@ do_modify(
                                (long) (*modtail)->ml_op, 0, 0 );
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
                            NULL, "unrecognized modify operation", NULL, NULL );
-                       free( dn );
-                       modlist_free( modlist );
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto cleanup;
                }
 
                if ( (*modtail)->ml_bvalues == NULL && (
@@ -144,9 +139,8 @@ do_modify(
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
                            NULL, "unrecognized modify operation without values",
                                NULL, NULL );
-                       free( dn );
-                       modlist_free( modlist );
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto cleanup;
                }
                attr_normalize( (*modtail)->ml_type );
 
@@ -165,30 +159,22 @@ do_modify(
 #endif
 
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
-               free( dn );
-               modlist_free( modlist );
                Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
-               return rc;
+               goto cleanup;
        } 
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
            op->o_connid, op->o_opid, dn, 0, 0 );
 
-       ndn = ch_strdup( ndn );
-       ldap_pvt_str2upper( ndn );
-
        /*
         * We could be serving multiple database backends.  Select the
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
        if ( (be = select_backend( ndn )) == NULL ) {
-               free( dn );
-               free( ndn );
-               modlist_free( modlist );
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, default_referral, NULL );
-               return rc;
+               goto cleanup;
        }
 
        if ( global_readonly || be->be_readonly ) {
@@ -196,7 +182,7 @@ do_modify(
                       0, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                                  NULL, "database is read-only", NULL, NULL );
-               goto done;
+               goto cleanup;
        }
 
        /* deref suffix alias if appropriate */
@@ -224,13 +210,10 @@ do_modify(
                                rc = add_modified_attrs( op, &modlist );
 
                                if( rc != LDAP_SUCCESS ) {
-                                       free( dn );
-                                       free( ndn );
-                                       modlist_free( modlist );
                                        send_ldap_result( conn, op, rc,
                                                NULL, "no-user-modification attribute type",
                                                NULL, NULL );
-                                       return rc;
+                                       goto cleanup;
                                }
                        }
 
@@ -257,10 +240,13 @@ do_modify(
                    NULL, "Function not implemented", NULL, NULL );
        }
 
-done:
+cleanup:
        free( dn );
        free( ndn );
-       modlist_free( modlist );
+       if ( modtail != NULL && *modtail != NULL )
+               free( *modtail );
+       if ( modlist != NULL )
+               modlist_free( modlist );
        return rc;
 }
 
index 60441237f48b67aebd0145a5659d381379a6ff00..7c8004cff82a5f851f1ed1eb34e6031379980ba4 100644 (file)
@@ -82,22 +82,20 @@ do_modrdn(
                return -1;
        }
 
-       if( dn_normalize( dn ) == NULL ) {
+       ndn = ch_strdup( dn );
+
+       if( dn_normalize_case( ndn ) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid dn (%s)\n", dn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
-               free( dn );
-               free( newrdn );
-               return rc;
+               goto cleanup;
        }
 
        if( !rdn_validate( newrdn ) ) {
                Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n", newrdn, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid RDN", NULL, NULL );
-               free( dn );
-               free( newrdn );
-               return rc;
+               goto cleanup;
        }
 
        /* Check for newSuperior parameter, if present scan it */
@@ -112,21 +110,19 @@ do_modrdn(
                               0, 0, 0 );
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "newSuperior requires LDAPv3" );
-                       free( dn );
-                       free( newrdn );
-                       return -1;
+                       rc = -1;
+                       goto cleanup;
                }
 
                if ( ber_scanf( op->o_ber, "a", &newSuperior ) 
                     == LBER_ERROR ) {
 
-                   Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\") failed\n",
+                       Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\") failed\n",
                           0, 0, 0 );
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "decoding error" );
-                       free( dn );
-                       free( newrdn );
-                   return -1;
+                       rc = -1;
+                       goto cleanup;
                }
 
                nnewSuperior = ch_strdup( newSuperior );
@@ -136,7 +132,7 @@ do_modrdn(
                                newSuperior, 0, 0 );
                        send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
                                "invalid (new superior) DN", NULL, NULL );
-                       goto done;
+                       goto cleanup;
                }
 
        }
@@ -147,20 +143,17 @@ do_modrdn(
                newSuperior != NULL ? newSuperior : "" );
 
        if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) {
-               free( dn );
-               free( newrdn ); 
-               free( newSuperior );
-               free( nnewSuperior );
                Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
                send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "decoding error" );
-               return -1;
+               rc = -1;
+               goto cleanup;
        }
 
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
                /* get_ctrls has sent results.  Now clean up. */
-               goto done;
+               goto cleanup;
        } 
 
        Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MODRDN dn=\"%s\"\n",
@@ -172,18 +165,10 @@ do_modrdn(
         * if we don't hold it.
         */
 
-       ndn = ch_strdup( dn );
-       ldap_pvt_str2upper( ndn );
-
        if ( (be = select_backend( ndn )) == NULL ) {
-               free( dn );
-               free( ndn );
-               free( newrdn ); 
-               free( newSuperior );
-               free( nnewSuperior );
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, default_referral, NULL );
-               return rc;
+               goto cleanup;
        }
 
        if ( global_readonly || be->be_readonly ) {
@@ -191,7 +176,7 @@ do_modrdn(
                       0, 0, 0 );
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                                  NULL, "database is read-only", NULL, NULL );
-               goto done;
+               goto cleanup;
        }
 
        /* Make sure that the entry being changed and the newSuperior are in 
@@ -207,13 +192,7 @@ do_modrdn(
                        send_ldap_result( conn, op, rc,
                                NULL, NULL, NULL, NULL );
 
-                       free( dn );
-                       free( ndn );
-                       free( newrdn );
-                       free( newSuperior );
-                       free( nnewSuperior );
-
-                       return rc;
+                       goto cleanup;
                }
 
                /* deref suffix alias if appropriate */
@@ -261,11 +240,13 @@ do_modrdn(
                        NULL, "Function not implemented", NULL, NULL );
        }
 
-done:
+cleanup:
        free( dn );
        free( ndn );
        free( newrdn ); 
-       free( newSuperior );
-       free( nnewSuperior );
+       if ( newSuperior != NULL )
+               free( newSuperior );
+       if ( nnewSuperior != NULL )
+               free( nnewSuperior );
        return rc;
 }
index 3e28c17ae7df5729b1b66cfefdf0ed985cede3b1..8d98fb0ae439580f7030cb29a977f8db9e94364b 100644 (file)
@@ -105,7 +105,9 @@ do_search(
                goto return_results;
        }
 
-       if( dn_normalize( base ) == NULL ) {
+       nbase = ch_strdup( base );
+
+       if( dn_normalize_case( nbase ) == NULL ) {
                send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX,
                        NULL, "invalid DN", NULL, NULL );
                rc = -1;
@@ -161,9 +163,6 @@ do_search(
            "conn=%ld op=%d SRCH base=\"%s\" scope=%d filter=\"%s\"\n",
            op->o_connid, op->o_opid, base, scope, fstr );
 
-       nbase = ch_strdup( base );
-       ldap_pvt_str2upper( nbase );
-
        if ( scope == LDAP_SCOPE_BASE ) {
 #if defined( SLAPD_MONITOR_DN )
                if ( strcmp( nbase, SLAPD_MONITOR_DN ) == 0 ) {