In ordered_value_sort, allow zero-length ordered values.

In check_vals, log msg when ordered_value_sort fails.
This commit is contained in:
Howard Chu 2005-08-28 10:23:10 +00:00
parent f8a97897ad
commit ba881c5e6f
2 changed files with 13 additions and 4 deletions

View file

@ -2909,8 +2909,11 @@ check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
sort = 1;
rc = ordered_value_sort( a, 1 );
if ( rc )
if ( rc ) {
sprintf(ca->msg, "ordered_value_sort failed on attr %s\n",
ad->ad_cname.bv_val );
return rc;
}
}
for ( i=0; vals[i].bv_val; i++ ) {
ca->line = vals[i].bv_val;

View file

@ -322,7 +322,7 @@ ordered_value_sort( Attribute *a, int do_renumber )
char *ptr;
index = 1;
ptr = strchr( a->a_vals[i].bv_val, '}' );
if ( !ptr || !ptr[1] )
if ( !ptr )
return LDAP_INVALID_SYNTAX;
if ( noindex )
return LDAP_INVALID_SYNTAX;
@ -361,8 +361,14 @@ ordered_value_sort( Attribute *a, int do_renumber )
#endif
indexes = ch_malloc( vals * sizeof(int) );
for ( i=0; i<vals; i++)
indexes[i] = strtol(a->a_vals[i].bv_val+1, NULL, 0);
for ( i=0; i<vals; i++) {
char *ptr;
indexes[i] = strtol(a->a_vals[i].bv_val+1, &ptr, 0);
if ( *ptr != '}' ) {
ch_free( indexes );
return LDAP_INVALID_SYNTAX;
}
}
/* Insertion sort */
for ( i=1; i<vals; i++ ) {