/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/*
{
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS;
- BerVarray nvals = NULL, nmods;
+ BerVarray nvals = NULL, nmods = NULL;
/*
* FIXME: better do the following
/* count existing values */ ;
if ( numvals < nummods ) {
- nvals = ch_calloc( numvals + 1, sizeof( struct berval ) );
+ nvals = SLAP_CALLOC( numvals + 1, sizeof( struct berval ) );
+ if( nvals == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
/* normalize the existing values first */
for ( j = 0; vals[ j ].bv_val != NULL; j++ ) {
* values and test each new value against them first,
* then to other already normalized values
*/
- nmods = ch_calloc( nummods + 1, sizeof( struct berval ) );
+ nmods = SLAP_CALLOC( nummods + 1, sizeof( struct berval ) );
+ if ( nmods == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
for ( i = 0; mods[ i ].bv_val != NULL; i++ ) {
rc = value_normalize( ad, SLAP_MR_EQUALITY,
mr, &nmods[ i ], &nvals[ j ] );
if ( rc != LDAP_SUCCESS ) {
nmods[ i + 1 ].bv_val = NULL;
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "%s: matching rule failed",
+ ad->ad_cname.bv_val );
goto return_results;
}
if ( match == 0 ) {
+ *text = textbuf;
snprintf( textbuf, textlen,
"%s: value #%d provided more than once",
ad->ad_cname.bv_val, i );
mr, &nmods[ i ], &nmods[ j ] );
if ( rc != LDAP_SUCCESS ) {
nmods[ i + 1 ].bv_val = NULL;
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "%s: matching rule failed",
+ ad->ad_cname.bv_val );
goto return_results;
}
if ( match == 0 ) {
+ *text = textbuf;
snprintf( textbuf, textlen,
"%s: value #%d provided more than once",
ad->ad_cname.bv_val, j );
ad->ad_type->sat_syntax,
mr, &nmods[ i ], &asserted );
if ( rc != LDAP_SUCCESS ) {
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "%s: matching rule failed",
+ ad->ad_cname.bv_val );
goto return_results;
}
if ( match == 0 ) {
+ *text = textbuf;
snprintf( textbuf, textlen,
"%s: value #%d provided more than once",
ad->ad_cname.bv_val, j );
}
} else {
-
/*
* The original code performs ( n ) normalizations
* and ( n * ( n - 1 ) / 2 ) matches, which hide
*/
int rc;
- const char *text = NULL;
- char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
if ( mod->sm_bvalues[ 1 ].bv_val == 0 ) {
if ( a != NULL ) {
int i;
rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
- &mod->sm_bvalues[ 0 ], &asserted, &text );
+ &mod->sm_bvalues[ 0 ], &asserted, text );
if ( rc != LDAP_SUCCESS ) {
return rc;
rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- &a->a_vals[ i ], &asserted, &text );
+ &a->a_vals[ i ], &asserted, text );
if( rc == LDAP_SUCCESS && match == 0 ) {
free( asserted.bv_val );
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "modify/%s: %s: value #0 already exists",
+ op, mod->sm_desc->ad_cname.bv_val, 0 );
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
} else {
rc = modify_check_duplicates( mod->sm_desc, mr,
a ? a->a_vals : NULL, mod->sm_bvalues,
- &text, textbuf, sizeof( textbuf ) );
+ text, textbuf, textlen );
if ( rc != LDAP_SUCCESS ) {
return rc;
for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ )
/* count existing values */ ;
- nvals = (BerVarray)ch_calloc( j + 1, sizeof ( struct berval ) );
+ nvals = (BerVarray)SLAP_CALLOC( j + 1, sizeof ( struct berval ) );
+ if( nvals == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
/* normalize existing values */
for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ ) {
if ( rc != LDAP_SUCCESS ) {
free( asserted.bv_val );
+ *text = textbuf;
+ snprintf( textbuf, textlen,
+ "%s: matching rule failed",
+ mod->sm_desc->ad_cname.bv_val );
goto return_results;
}