]> git.sur5r.net Git - openldap/commitdiff
In ordered_value_sort, allow zero-length ordered values.
authorHoward Chu <hyc@openldap.org>
Sun, 28 Aug 2005 10:23:10 +0000 (10:23 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 28 Aug 2005 10:23:10 +0000 (10:23 +0000)
In check_vals, log msg when ordered_value_sort fails.

servers/slapd/bconfig.c
servers/slapd/value.c

index 2499369b6d038459a2e1655fa5fa2daf4754f299..4229c9be024f99684e66170da64084a165c54392 100644 (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;
index 898715ed4c744c3505f1b050679c73fb338f6710..280ab4af5736de9697de846b86a41e0d19cdd4d7 100644 (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++ ) {