#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
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;
}
idx = p - left.bv_val;
- assert( idx < left.bv_len );
if( idx >= left.bv_len ) {
/* this shouldn't happen */
}
idx = p - left.bv_val;
- assert( idx < left.bv_len );
if( idx >= left.bv_len ) {
/* this shouldn't happen */
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;