From ba881c5e6fc779cf2bb00f02476f0ec5121a9ddd Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 28 Aug 2005 10:23:10 +0000 Subject: [PATCH] In ordered_value_sort, allow zero-length ordered values. In check_vals, log msg when ordered_value_sort fails. --- servers/slapd/bconfig.c | 5 ++++- servers/slapd/value.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 2499369b6d..4229c9be02 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -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; diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 898715ed4c..280ab4af57 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -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; ia_vals[i].bv_val+1, NULL, 0); + for ( i=0; ia_vals[i].bv_val+1, &ptr, 0); + if ( *ptr != '}' ) { + ch_free( indexes ); + return LDAP_INVALID_SYNTAX; + } + } /* Insertion sort */ for ( i=1; i