mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
behave when a value of an ordered attr starts with '{' and either contains or not '}', but the prefix '{X}' does not contain a numericString
This commit is contained in:
parent
285ceff179
commit
72f009ac52
@ -1618,6 +1618,9 @@ LDAP_SLAPD_F( slap_mr_filter_func ) octetStringFilter;
|
||||
LDAP_SLAPD_F( int ) numericoidValidate LDAP_P((
|
||||
Syntax *syntax,
|
||||
struct berval *in ));
|
||||
LDAP_SLAPD_F( int ) numericStringValidate LDAP_P((
|
||||
Syntax *syntax,
|
||||
struct berval *in ));
|
||||
LDAP_SLAPD_F( int ) octetStringMatch LDAP_P((
|
||||
int *matchp,
|
||||
slap_mask_t flags,
|
||||
@ -1625,6 +1628,13 @@ LDAP_SLAPD_F( int ) octetStringMatch LDAP_P((
|
||||
MatchingRule *mr,
|
||||
struct berval *value,
|
||||
void *assertedValue ));
|
||||
LDAP_SLAPD_F( int ) octetStringOrderingMatch LDAP_P((
|
||||
int *matchp,
|
||||
slap_mask_t flags,
|
||||
Syntax *syntax,
|
||||
MatchingRule *mr,
|
||||
struct berval *value,
|
||||
void *assertedValue ));
|
||||
|
||||
/*
|
||||
* schema_prep.c
|
||||
|
@ -280,7 +280,7 @@ octetStringMatch(
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
octetStringOrderingMatch(
|
||||
int *matchp,
|
||||
slap_mask_t flags,
|
||||
@ -2385,7 +2385,7 @@ UUIDNormalize(
|
||||
|
||||
|
||||
|
||||
static int
|
||||
int
|
||||
numericStringValidate(
|
||||
Syntax *syntax,
|
||||
struct berval *in )
|
||||
|
@ -430,19 +430,26 @@ ordered_value_validate(
|
||||
|
||||
/* Skip past the assertion index */
|
||||
if ( bv.bv_val[0] == '{' ) {
|
||||
char *ptr;
|
||||
char *ptr;
|
||||
|
||||
ptr = ber_bvchr( &bv, '}' );
|
||||
if ( ptr == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
if ( ptr != NULL ) {
|
||||
struct berval ns;
|
||||
|
||||
ns.bv_val = bv.bv_val + 1;
|
||||
ns.bv_len = ptr - ns.bv_val;
|
||||
|
||||
if ( numericStringValidate( NULL, &ns ) == LDAP_SUCCESS ) {
|
||||
ptr++;
|
||||
bv.bv_len -= ptr - bv.bv_val;
|
||||
bv.bv_val = ptr;
|
||||
in = &bv;
|
||||
/* If deleting by index, just succeed */
|
||||
if ( mop == LDAP_MOD_DELETE && BER_BVISEMPTY( &bv ) ) {
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
bv.bv_len -= ptr - bv.bv_val;
|
||||
bv.bv_val = ptr;
|
||||
in = &bv;
|
||||
/* If deleting by index, just succeed */
|
||||
if ( mop == LDAP_MOD_DELETE && BER_BVISEMPTY( &bv ))
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,18 +485,24 @@ ordered_value_pretty(
|
||||
char *ptr;
|
||||
|
||||
ptr = ber_bvchr( &bv, '}' );
|
||||
if ( ptr == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
if ( ptr != NULL ) {
|
||||
struct berval ns;
|
||||
|
||||
ns.bv_val = bv.bv_val + 1;
|
||||
ns.bv_len = ptr - ns.bv_val;
|
||||
|
||||
if ( numericStringValidate( NULL, &ns ) == LDAP_SUCCESS ) {
|
||||
ptr++;
|
||||
|
||||
idx = bv;
|
||||
idx.bv_len = ptr - bv.bv_val;
|
||||
|
||||
bv.bv_len -= idx.bv_len;
|
||||
bv.bv_val = ptr;
|
||||
|
||||
val = &bv;
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
|
||||
idx = bv;
|
||||
idx.bv_len = ptr - bv.bv_val;
|
||||
|
||||
bv.bv_len -= idx.bv_len;
|
||||
bv.bv_val = ptr;
|
||||
|
||||
val = &bv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,23 +554,29 @@ ordered_value_normalize(
|
||||
char *ptr;
|
||||
|
||||
ptr = ber_bvchr( &bv, '}' );
|
||||
if ( ptr == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
if ( ptr != NULL ) {
|
||||
struct berval ns;
|
||||
|
||||
ns.bv_val = bv.bv_val + 1;
|
||||
ns.bv_len = ptr - ns.bv_val;
|
||||
|
||||
if ( numericStringValidate( NULL, &ns ) == LDAP_SUCCESS ) {
|
||||
ptr++;
|
||||
|
||||
idx = bv;
|
||||
idx.bv_len = ptr - bv.bv_val;
|
||||
|
||||
bv.bv_len -= idx.bv_len;
|
||||
bv.bv_val = ptr;
|
||||
|
||||
/* validator will already prevent this for Adds */
|
||||
if ( BER_BVISEMPTY( &bv )) {
|
||||
ber_dupbv_x( normalized, &idx, ctx );
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
val = &bv;
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
|
||||
idx = bv;
|
||||
idx.bv_len = ptr - bv.bv_val;
|
||||
|
||||
bv.bv_len -= idx.bv_len;
|
||||
bv.bv_val = ptr;
|
||||
|
||||
/* validator will already prevent this for Adds */
|
||||
if ( BER_BVISEMPTY( &bv )) {
|
||||
ber_dupbv_x( normalized, &idx, ctx );
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
val = &bv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,54 +628,57 @@ ordered_value_match(
|
||||
*/
|
||||
if ( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
|
||||
char *ptr;
|
||||
struct berval iv;
|
||||
struct berval ns1 = BER_BVNULL, ns2 = BER_BVNULL;
|
||||
|
||||
bv1 = *v1;
|
||||
bv2 = *v2;
|
||||
iv = bv2;
|
||||
|
||||
/* Skip past the assertion index */
|
||||
if ( bv2.bv_val[0] == '{' ) {
|
||||
ptr = ber_bvchr( &bv2, '}' );
|
||||
if ( ptr == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
if ( ptr != NULL ) {
|
||||
ns2.bv_val = bv2.bv_val + 1;
|
||||
ns2.bv_len = ptr - ns2.bv_val;
|
||||
|
||||
if ( numericStringValidate( NULL, &ns2 ) == LDAP_SUCCESS ) {
|
||||
ptr++;
|
||||
bv2.bv_len -= ptr - bv2.bv_val;
|
||||
bv2.bv_val = ptr;
|
||||
v2 = &bv2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip past the attribute index */
|
||||
if ( bv1.bv_val[0] == '{' ) {
|
||||
ptr = ber_bvchr( &bv1, '}' );
|
||||
if ( ptr != NULL ) {
|
||||
ns1.bv_val = bv1.bv_val + 1;
|
||||
ns1.bv_len = ptr - ns1.bv_val;
|
||||
|
||||
if ( numericStringValidate( NULL, &ns1 ) == LDAP_SUCCESS ) {
|
||||
ptr++;
|
||||
bv1.bv_len -= ptr - bv1.bv_val;
|
||||
bv1.bv_val = ptr;
|
||||
v1 = &bv1;
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
bv2.bv_len -= ptr - bv2.bv_val;
|
||||
bv2.bv_val = ptr;
|
||||
v2 = &bv2;
|
||||
}
|
||||
|
||||
if ( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( flags )) {
|
||||
if ( iv.bv_val[0] == '{' && bv1.bv_val[0] == '{' ) {
|
||||
/* compare index values first */
|
||||
long l1, l2, ret;
|
||||
|
||||
l1 = strtol( bv1.bv_val+1, NULL, 0 );
|
||||
l2 = strtol( iv.bv_val+1, &ptr, 0 );
|
||||
|
||||
ret = l1 - l2;
|
||||
if ( !BER_BVISNULL( &ns2 ) && !BER_BVISNULL( &ns1 ) ) {
|
||||
/* compare index values first */
|
||||
(void)octetStringOrderingMatch( match, 0, NULL, NULL, &ns1, &ns2 );
|
||||
|
||||
/* If not equal, or we're only comparing the index,
|
||||
* return result now.
|
||||
*/
|
||||
if ( ret || ptr == iv.bv_val + iv.bv_len - 1 ) {
|
||||
*match = ( ret < 0 ) ? -1 : (ret > 0 );
|
||||
if ( *match != 0 || BER_BVISEMPTY( &bv2 ) ) {
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Skip past the attribute index */
|
||||
if ( bv1.bv_val[0] == '{' ) {
|
||||
ptr = ber_bvchr( &bv1, '}' );
|
||||
if ( ptr == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
}
|
||||
ptr++;
|
||||
bv1.bv_len -= ptr - bv1.bv_val;
|
||||
bv1.bv_val = ptr;
|
||||
v1 = &bv1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !mr || !mr->smr_match ) {
|
||||
@ -712,6 +734,7 @@ ordered_value_add(
|
||||
|
||||
k = -1;
|
||||
if ( vals[i].bv_val[0] == '{' ) {
|
||||
/* FIXME: strtol() could go past end... */
|
||||
k = strtol( vals[i].bv_val + 1, &next, 0 );
|
||||
if ( next == vals[i].bv_val + 1 ||
|
||||
next[ 0 ] != '}' ||
|
||||
|
Loading…
Reference in New Issue
Block a user