mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
substrings match works with NULs in UTF8 strings
This commit is contained in:
parent
55993dc66a
commit
215448ac83
@ -83,6 +83,9 @@ ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
|
||||
#define ber_strccmp(s,c) \
|
||||
( (s)[0] == (c) && (s)[1] == '\0' )
|
||||
|
||||
LBER_F( char * )
|
||||
ber_bvchr LDAP_P(( struct berval *bv, char c ));
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif
|
||||
|
@ -697,3 +697,26 @@ ber_bvarray_add( BerVarray *a, BerValue *bv )
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
char *
|
||||
ber_bvchr( struct berval *bv, char c )
|
||||
{
|
||||
ber_len_t p;
|
||||
|
||||
assert( bv );
|
||||
|
||||
if ( bv->bv_len == 0 ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert( bv->bv_val );
|
||||
|
||||
for ( p = 0; p < bv->bv_len; p++ ) {
|
||||
if ( bv->bv_val[ p ] == c ) {
|
||||
return &bv->bv_val[ p ];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -529,13 +529,7 @@ UTF8StringNormalize(
|
||||
|
||||
/* Ignore initial whitespace */
|
||||
/* All space is ASCII. All ASCII is 1 byte */
|
||||
while ( ASCII_SPACE( *p ) ) {
|
||||
p++;
|
||||
}
|
||||
|
||||
if( *p == '\0' ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
}
|
||||
for ( ; p < val->bv_val + val->bv_len && ASCII_SPACE( p[ 0 ] ); p++ );
|
||||
|
||||
ber_mem2bv( p, val->bv_len - (p - val->bv_val), 1, normalized );
|
||||
e = normalized->bv_val + val->bv_len - (p - val->bv_val);
|
||||
@ -1046,7 +1040,7 @@ caseExactIgnoreSubstringsMatch(
|
||||
struct berval left = { 0, NULL };
|
||||
int i;
|
||||
ber_len_t inlen=0;
|
||||
char *nav;
|
||||
char *nav = NULL;
|
||||
unsigned casefold;
|
||||
|
||||
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
|
||||
@ -1083,7 +1077,7 @@ caseExactIgnoreSubstringsMatch(
|
||||
goto done;
|
||||
}
|
||||
|
||||
match = strncmp( sub->sa_initial.bv_val, left.bv_val,
|
||||
match = memcmp( sub->sa_initial.bv_val, left.bv_val,
|
||||
sub->sa_initial.bv_len );
|
||||
|
||||
if( match != 0 ) {
|
||||
@ -1101,7 +1095,7 @@ caseExactIgnoreSubstringsMatch(
|
||||
goto done;
|
||||
}
|
||||
|
||||
match = strncmp( sub->sa_final.bv_val,
|
||||
match = memcmp( sub->sa_final.bv_val,
|
||||
&left.bv_val[left.bv_len - sub->sa_final.bv_len],
|
||||
sub->sa_final.bv_len );
|
||||
|
||||
@ -1129,9 +1123,9 @@ retry:
|
||||
continue;
|
||||
}
|
||||
|
||||
p = strchr( left.bv_val, *sub->sa_any[i].bv_val );
|
||||
p = ber_bvchr( &left, *sub->sa_any[i].bv_val );
|
||||
|
||||
if( p == NULL ) {
|
||||
if ( p == NULL ) {
|
||||
match = 1;
|
||||
goto done;
|
||||
}
|
||||
@ -1160,7 +1154,7 @@ retry:
|
||||
goto done;
|
||||
}
|
||||
|
||||
match = strncmp( left.bv_val,
|
||||
match = memcmp( left.bv_val,
|
||||
sub->sa_any[i].bv_val,
|
||||
sub->sa_any[i].bv_len );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user