]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_init.c
add Time subsystem
[openldap] / servers / slapd / schema_init.c
index bf1484603d204a32da774ede64107787ddd365ea..a6e68b5316721997755004752f622fd9712cbcb8 100644 (file)
 #define caseExactMatchOID                      "2.5.13.5"
 #define caseExactSubstringsMatchOID            "2.5.13.7"
 
-static char *strcasechr( const char *str, int c )
+static char *bvcasechr( struct berval *bv, int c, ber_len_t *len )
 {
-       char *lower = strchr( str, TOLOWER(c) );
-       char *upper = strchr( str, TOUPPER(c) );
+       ber_len_t i;
+       int lower = TOLOWER( c );
+       int upper = TOUPPER( c );
 
-       if( lower && upper ) {
-               return lower < upper ? lower : upper;
-       } else if ( lower ) {
-               return lower;
-       } else {
-               return upper;
+       if( c == 0 ) return NULL;
+       
+       for( i=0; i < bv->bv_len; i++ ) {
+               if( upper == bv->bv_val[i] || lower == bv->bv_val[i] ) {
+                       *len = i;
+                       return &bv->bv_val[i];
+               }
        }
+
+       return NULL;
 }
 
 static int
@@ -471,34 +475,32 @@ UTF8StringValidate(
 
        for( count = in->bv_len; count > 0; count-=len, u+=len ) {
                /* get the length indicated by the first byte */
-               len = LDAP_UTF8_CHARLEN( u );
+               len = LDAP_UTF8_CHARLEN2( u, len );
 
                /* very basic checks */
                switch( len ) {
                        case 6:
-                               if( u[5] >= 0xFE ) {
+                               if( (u[5] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 5:
-                               if( u[4] >= 0xFE ) {
+                               if( (u[4] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 4:
-                               if( u[3] >= 0xFE ) {
+                               if( (u[3] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 3:
-                               if( u[2] >= 0xFE ) {
+                               if( (u[2] & 0xC0 )!= 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 2:
-                               if( u[1] >= 0xFE ) {
+                               if( (u[1] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 1:
-                               if( u[0] >= 0xFE ) {
-                                       return LDAP_INVALID_SYNTAX;
-                               }
+                               /* CHARLEN already validated it */
                                break;
                        default:
                                return LDAP_INVALID_SYNTAX;
@@ -1138,7 +1140,6 @@ retry:
                        }
 
                        idx = p - left.bv_val;
-                       assert( idx < left.bv_len );
 
                        if( idx >= left.bv_len ) {
                                /* this shouldn't happen */
@@ -2169,7 +2170,6 @@ retry:
                        }
 
                        idx = p - left.bv_val;
-                       assert( idx < left.bv_len );
 
                        if( idx >= left.bv_len ) {
                                /* this shouldn't happen */
@@ -2726,16 +2726,14 @@ retry:
                                continue;
                        }
 
-                       p = strcasechr( left.bv_val, *sub->sa_any[i].bv_val );
+                       p = bvcasechr( &left, *sub->sa_any[i].bv_val, &idx );
 
                        if( p == NULL ) {
                                match = 1;
                                goto done;
                        }
 
-                       idx = p - left.bv_val;
                        assert( idx < left.bv_len );
-
                        if( idx >= left.bv_len ) {
                                /* this shouldn't happen */
                                return LDAP_OTHER;