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 ) {
Operation *op
)
{
- char *dn, *ndn;
+ char *dn = NULL, *ndn=NULL;
Ava ava;
Backend *be;
int rc = LDAP_SUCCESS;
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 ) );
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 */
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 );
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"
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 */
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;
}
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
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;
{
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;
(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 && (
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 );
#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 ) {
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 */
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;
}
}
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;
}
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 */
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 );
newSuperior, 0, 0 );
send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
"invalid (new superior) DN", NULL, NULL );
- goto done;
+ goto cleanup;
}
}
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",
* 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 ) {
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
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 */
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;
}
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;
"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 ) {