#include "slap.h"
#include "ldap_pvt.h"
-#define UTF8MATCH 1
-
-#ifdef USE_MD5
-#include "lutil_md5.h"
-/* We should replace MD5 with a faster hash */
-#define HASH_BYTES LUTIL_MD5_BYTES
-#define HASH_CONTEXT lutil_MD5_CTX
-#define HASH_Init(c) lutil_MD5Init(c)
-#define HASH_Update(c,buf,len) lutil_MD5Update(c,buf,len)
-#define HASH_Final(d,c) lutil_MD5Final(d,c)
-#else
#include "lutil_hash.h"
/* We should replace MD5 with a faster hash */
#define HASH_BYTES LUTIL_HASH_BYTES
#define HASH_Init(c) lutil_HASHInit(c)
#define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
#define HASH_Final(d,c) lutil_HASHFinal(d,c)
-#endif
/* recycled validatation routines */
#define berValidate blobValidate
dn = ch_strdup( in->bv_val );
if( dn == NULL ) {
- return LDAP_INVALID_DN;
+ return LDAP_INVALID_SYNTAX;
} else if ( strlen( in->bv_val ) != in->bv_len ) {
- rc = LDAP_INVALID_DN;
+ rc = LDAP_INVALID_SYNTAX;
} else if ( dn_validate( dn ) == NULL ) {
- rc = LDAP_INVALID_DN;
+ rc = LDAP_INVALID_SYNTAX;
} else {
rc = LDAP_SUCCESS;
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
- "dnMatch: %d\n %s\n %s\n", match,
- value->bv_val, asserted->bv_val ));
+ "dnMatch: %d\n %s\n %s\n", match,
+ value->bv_val, asserted->bv_val ));
#else
Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n",
- match, value->bv_val, asserted->bv_val );
+ match, value->bv_val, asserted->bv_val );
#endif
return LDAP_SUCCESS;
}
-#if UTF8MATCH
/* Returns Unicode cannonically normalized copy of a substring assertion
* Skipping attribute description */
SubstringsAssertion *
ch_free( nsa );
return NULL;
}
-#endif
#if defined(SLAPD_APPROX_MULTISTRING)
/* Allocate/increase storage to account for new keys */
newkeys = (struct berval **)ch_malloc( (keycount + wordcount + 1)
- * sizeof(struct berval *) );
+ * sizeof(struct berval *) );
memcpy( newkeys, keys, keycount * sizeof(struct berval *) );
if( keys ) ch_free( keys );
keys = newkeys;
struct berval *value,
void *assertedValue )
{
-#if UTF8MATCH
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
UTF8_NOCASEFOLD );
-#else
- int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
-
- if( match == 0 ) {
- match = strncmp( value->bv_val,
- ((struct berval *) assertedValue)->bv_val,
- value->bv_len );
- }
-
- *matchp = match;
-#endif
return LDAP_SUCCESS;
}
struct berval left;
int i;
ber_len_t inlen=0;
-#if UTF8MATCH
char *nav;
-#endif
-#if UTF8MATCH
nav = UTF8normalize( value->bv_val, UTF8_NOCASEFOLD );
if( nav == NULL ) {
match = 1;
}
left.bv_val = nav;
left.bv_len = strlen( nav );
+
sub = UTF8SubstringsassertionNormalize( assertedValue, UTF8_NOCASEFOLD );
-#else
- left = *value;
- sub = assertedValue;
-#endif
if( sub == NULL ) {
match = -1;
goto done;
}
done:
-#if UTF8MATCH
free( nav );
if( sub != NULL ) {
ch_free( sub->sa_final );
ch_free( sub->sa_initial );
ch_free( sub );
}
-#endif
*matchp = match;
return LDAP_SUCCESS;
}
for( i=0; values[i] != NULL; i++ ) {
struct berval *value;
-#if UTF8MATCH
- value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_NOCASEFOLD ) );
-#else
- value = values[i];
-#endif
+ value = ber_bvstr( UTF8normalize( values[i]->bv_val,
+ UTF8_NOCASEFOLD ) );
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
value->bv_val, value->bv_len );
HASH_Final( HASHdigest, &HASHcontext );
-#if UTF8MATCH
ber_bvfree( value );
-#endif
keys[i] = ber_bvdup( &digest );
}
slen = strlen( syntax->ssyn_oid );
mlen = strlen( mr->smr_oid );
-#if UTF8MATCH
value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue)->bv_val,
UTF8_NOCASEFOLD ) );
/* This usually happens if filter contains bad UTF8 */
keys[0] = NULL;
return LDAP_SUCCESS;
}
-#else
- value = (struct berval *) assertValue;
-#endif
keys = ch_malloc( sizeof( struct berval * ) * 2 );
ber_len_t i, nkeys;
size_t slen, mlen;
struct berval **keys;
-#if UTF8MATCH
- struct berval **nvalues;
-#endif
+ struct berval **nvalues;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
nkeys=0;
-#if UTF8MATCH
- /* create normalized copy of values */
- for( i=0; values[i] != NULL; i++ ) {
- /* empty */
- }
- nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) );
- for( i=0; values[i] != NULL; i++ ) {
- nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_NOCASEFOLD ) );
- }
- nvalues[i] = NULL;
- values = nvalues;
-#endif
+ /* create normalized copy of values */
+ for( i=0; values[i] != NULL; i++ ) {
+ /* empty */
+ }
+ nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) );
+ for( i=0; values[i] != NULL; i++ ) {
+ nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val,
+ UTF8_NOCASEFOLD ) );
+ }
+ nvalues[i] = NULL;
+ values = nvalues;
for( i=0; values[i] != NULL; i++ ) {
/* count number of indices to generate */
*keysp = NULL;
}
-#if UTF8MATCH
ber_bvecfree( nvalues );
-#endif
return LDAP_SUCCESS;
}
struct berval *value;
struct berval digest;
-#if UTF8MATCH
- sa = UTF8SubstringsassertionNormalize( assertValue, UTF8_NOCASEFOLD );
-#else
- sa = assertValue;
-#endif
+ sa = UTF8SubstringsassertionNormalize( assertValue, UTF8_NOCASEFOLD );
if( sa == NULL ) {
- *keysp = NULL;
- return LDAP_SUCCESS;
- }
+ *keysp = NULL;
+ return LDAP_SUCCESS;
+ }
if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
ch_free( keys );
*keysp = NULL;
}
-#if UTF8MATCH
ch_free( sa->sa_final );
ber_bvecfree( sa->sa_any );
ch_free( sa->sa_initial );
ch_free( sa );
-#endif
return LDAP_SUCCESS;
}
struct berval *value,
void *assertedValue )
{
-#if UTF8MATCH
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
UTF8_CASEFOLD );
-#else
- int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
-
- if( match == 0 ) {
- match = strncasecmp( value->bv_val,
- ((struct berval *) assertedValue)->bv_val,
- value->bv_len );
- }
-
- *matchp = match;
-#endif
return LDAP_SUCCESS;
}
struct berval left;
int i;
ber_len_t inlen=0;
-#if UTF8MATCH
char *nav;
-#endif
-#if UTF8MATCH
nav = UTF8normalize( value->bv_val, UTF8_CASEFOLD );
if( nav == NULL ) {
match = 1;
goto done;
- }
+ }
left.bv_val = nav;
left.bv_len = strlen( nav );
+
sub = UTF8SubstringsassertionNormalize( assertedValue, UTF8_CASEFOLD );
-#else
- left = *value;
- sub = assertedValue;
-#endif
if( sub == NULL ) {
match = -1;
goto done;
- }
+ }
/* Add up asserted input length */
if( sub->sa_initial ) {
goto done;
}
-#if UTF8MATCH
match = strncmp( sub->sa_initial->bv_val, left.bv_val,
sub->sa_initial->bv_len );
-#else
- match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
- sub->sa_initial->bv_len );
-#endif
if( match != 0 ) {
goto done;
goto done;
}
-#if UTF8MATCH
match = strncmp( sub->sa_final->bv_val,
&left.bv_val[left.bv_len - sub->sa_final->bv_len],
sub->sa_final->bv_len );
-#else
- match = strncasecmp( sub->sa_final->bv_val,
- &left.bv_val[left.bv_len - sub->sa_final->bv_len],
- sub->sa_final->bv_len );
-#endif
if( match != 0 ) {
goto done;
continue;
}
-#if UTF8MATCH
p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
-#else
- p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
-#endif
if( p == NULL ) {
match = 1;
goto done;
}
-#if UTF8MATCH
match = strncmp( left.bv_val,
sub->sa_any[i]->bv_val,
sub->sa_any[i]->bv_len );
-#else
- match = strncasecmp( left.bv_val,
- sub->sa_any[i]->bv_val,
- sub->sa_any[i]->bv_len );
-#endif
if( match != 0 ) {
left.bv_val++;
}
done:
-#if UTF8MATCH
free( nav );
if( sub != NULL ) {
ch_free( sub->sa_final );
ch_free( sub->sa_initial );
ch_free( sub );
}
-#endif
*matchp = match;
return LDAP_SUCCESS;
}
for( i=0; values[i] != NULL; i++ ) {
struct berval *value;
-#if UTF8MATCH
value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_CASEFOLD ) );
-#else
- value = ber_bvdup( values[i] );
- ldap_pvt_str2upper( value->bv_val );
-#endif
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
HASH_Update( &HASHcontext,
slen = strlen( syntax->ssyn_oid );
mlen = strlen( mr->smr_oid );
-#if UTF8MATCH
value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue)->bv_val,
UTF8_CASEFOLD ) );
/* This usually happens if filter contains bad UTF8 */
keys[0] = NULL;
return LDAP_SUCCESS;
}
-#else
- value = ber_bvdup( (struct berval *) assertValue );
- ldap_pvt_str2upper( value->bv_val );
-#endif
keys = ch_malloc( sizeof( struct berval * ) * 2 );
ber_len_t i, nkeys;
size_t slen, mlen;
struct berval **keys;
-#if UTF8MATCH
struct berval **nvalues;
-#endif
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
nkeys=0;
-#if UTF8MATCH
/* create normalized copy of values */
for( i=0; values[i] != NULL; i++ ) {
/* empty */
}
nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) );
for( i=0; values[i] != NULL; i++ ) {
- nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_CASEFOLD ) );
+ nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val,
+ UTF8_CASEFOLD ) );
}
nvalues[i] = NULL;
values = nvalues;
-#endif
for( i=0; values[i] != NULL; i++ ) {
/* count number of indices to generate */
if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
-#if UTF8MATCH
value = values[i];
-#else
- value = ber_bvdup( values[i] );
- ldap_pvt_str2upper( value->bv_val );
-#endif
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
}
}
-#if !UTF8MATCH
- ber_bvfree( value );
-#endif
}
if( nkeys > 0 ) {
*keysp = NULL;
}
-#if UTF8MATCH
ber_bvecfree( nvalues );
-#endif
return LDAP_SUCCESS;
}
struct berval *value;
struct berval digest;
-#if UTF8MATCH
sa = UTF8SubstringsassertionNormalize( assertValue, UTF8_CASEFOLD );
-#else
- sa = assertValue;
-#endif
if( sa == NULL ) {
*keysp = NULL;
return LDAP_SUCCESS;
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
-#if UTF8MATCH
value = sa->sa_initial;
-#else
- value = ber_bvdup( sa->sa_initial );
- ldap_pvt_str2upper( value->bv_val );
-#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
value->bv_val, klen );
HASH_Final( HASHdigest, &HASHcontext );
-#if !UTF8MATCH
- ber_bvfree( value );
-#endif
keys[nkeys++] = ber_bvdup( &digest );
}
continue;
}
-#if UTF8MATCH
value = sa->sa_any[i];
-#else
- value = ber_bvdup( sa->sa_any[i] );
- ldap_pvt_str2upper( value->bv_val );
-#endif
for(j=0;
j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
keys[nkeys++] = ber_bvdup( &digest );
}
-
-#if !UTF8MATCH
- ber_bvfree( value );
-#endif
}
}
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
-#if UTF8MATCH
value = sa->sa_final;
-#else
- value = ber_bvdup( sa->sa_final );
- ldap_pvt_str2upper( value->bv_val );
-#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
&value->bv_val[value->bv_len-klen], klen );
HASH_Final( HASHdigest, &HASHcontext );
-#if !UTF8MATCH
- ber_bvfree( value );
-#endif
keys[nkeys++] = ber_bvdup( &digest );
}
ch_free( keys );
*keysp = NULL;
}
-#if UTF8MATCH
ch_free( sa->sa_final );
ber_bvecfree( sa->sa_any );
ch_free( sa->sa_initial );
ch_free( sa );
-#endif
return LDAP_SUCCESS;
}
#else
Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
"%d\n\t\"%s\"\n\t\"%s\"\n",
- match, value->bv_val, asserted->bv_val );
+ match, value->bv_val, asserted->bv_val );
#endif
p = (char *)val->bv_val;
e = p + val->bv_len;
-#if 0
- /* syntax does not allow leading white space */
- /* Ignore initial whitespace */
- while ( ( p < e ) && ASCII_SPACE( *p ) ) {
- p++;
- }
-#endif
-
if ( *p != '(' /*')'*/ ) {
return LDAP_INVALID_SYNTAX;
}
p++;
-#if 0
- /* syntax does not allow trailing white space */
- /* Ignore trailing whitespace */
- while ( ( p < e ) && ASCII_SPACE( *p ) ) {
- p++;
- }
-#endif
-
if (p != e) {
return LDAP_INVALID_SYNTAX;
}
for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
res = register_syntax( syntax_defs[i].sd_desc,
- syntax_defs[i].sd_flags,
- syntax_defs[i].sd_validate,
- syntax_defs[i].sd_normalize,
+ syntax_defs[i].sd_flags,
+ syntax_defs[i].sd_validate,
+ syntax_defs[i].sd_normalize,
syntax_defs[i].sd_pretty
#ifdef SLAPD_BINARY_CONVERSION
,
- syntax_defs[i].sd_ber2str,
+ syntax_defs[i].sd_ber2str,
syntax_defs[i].sd_str2ber
#endif
);
mrule_defs[i].mrd_usage,
mrule_defs[i].mrd_convert,
mrule_defs[i].mrd_normalize,
- mrule_defs[i].mrd_match,
+ mrule_defs[i].mrd_match,
mrule_defs[i].mrd_indexer,
mrule_defs[i].mrd_filter,
mrule_defs[i].mrd_associated );