Commit aa225c2c authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Explicitly mark attribute/assertion syntax of values to be normalized

parent dee604c6
...@@ -162,7 +162,9 @@ attr_merge_normalize( ...@@ -162,7 +162,9 @@ attr_merge_normalize(
BerVarray nvals = NULL; BerVarray nvals = NULL;
int rc; int rc;
if ( desc->ad_type->sat_equality && desc->ad_type->sat_equality->smr_normalize ) { if ( desc->ad_type->sat_equality &&
desc->ad_type->sat_equality->smr_normalize )
{
int i; int i;
for ( i = 0; vals[i].bv_val; i++ ); for ( i = 0; vals[i].bv_val; i++ );
...@@ -170,7 +172,7 @@ attr_merge_normalize( ...@@ -170,7 +172,7 @@ attr_merge_normalize(
nvals = sl_calloc( sizeof(struct berval), i + 1, memctx ); nvals = sl_calloc( sizeof(struct berval), i + 1, memctx );
for ( i = 0; vals[i].bv_val; i++ ) { for ( i = 0; vals[i].bv_val; i++ ) {
rc = (*desc->ad_type->sat_equality->smr_normalize)( rc = (*desc->ad_type->sat_equality->smr_normalize)(
0, SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
desc->ad_type->sat_syntax, desc->ad_type->sat_syntax,
desc->ad_type->sat_equality, desc->ad_type->sat_equality,
&vals[i], &nvals[i], memctx ); &vals[i], &nvals[i], memctx );
...@@ -235,9 +237,11 @@ attr_merge_normalize_one( ...@@ -235,9 +237,11 @@ attr_merge_normalize_one(
struct berval *nvalp; struct berval *nvalp;
int rc; int rc;
if ( desc->ad_type->sat_equality && desc->ad_type->sat_equality->smr_normalize ) { if ( desc->ad_type->sat_equality &&
desc->ad_type->sat_equality->smr_normalize )
{
rc = (*desc->ad_type->sat_equality->smr_normalize)( rc = (*desc->ad_type->sat_equality->smr_normalize)(
0, SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
desc->ad_type->sat_syntax, desc->ad_type->sat_syntax,
desc->ad_type->sat_equality, desc->ad_type->sat_equality,
val, &nval, memctx ); val, &nval, memctx );
......
...@@ -122,7 +122,7 @@ monitor_subsys_log_init( ...@@ -122,7 +122,7 @@ monitor_subsys_log_init(
int rc; int rc;
rc = (*mi->mi_ad_managedInfo->ad_type->sat_equality->smr_normalize)( rc = (*mi->mi_ad_managedInfo->ad_type->sat_equality->smr_normalize)(
0, SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
mi->mi_ad_managedInfo->ad_type->sat_syntax, mi->mi_ad_managedInfo->ad_type->sat_syntax,
mi->mi_ad_managedInfo->ad_type->sat_equality, mi->mi_ad_managedInfo->ad_type->sat_equality,
&int_2_level[ i ].s, &int_2_level[ i ].s,
......
...@@ -314,7 +314,7 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) ...@@ -314,7 +314,7 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx )
* if value is empty, use empty_bv * if value is empty, use empty_bv
*/ */
rc = ( *normf )( rc = ( *normf )(
0, SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
ad->ad_type->sat_syntax, ad->ad_type->sat_syntax,
mr, mr,
ava->la_value.bv_len ava->la_value.bv_len
......
...@@ -734,7 +734,7 @@ int slap_mods_check( ...@@ -734,7 +734,7 @@ int slap_mods_check(
for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) { for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
rc = ad->ad_type->sat_equality->smr_normalize( rc = ad->ad_type->sat_equality->smr_normalize(
0, SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad->ad_type->sat_syntax, ad->ad_type->sat_syntax,
ad->ad_type->sat_equality, ad->ad_type->sat_equality,
&ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx ); &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
......
...@@ -495,7 +495,7 @@ slap_modrdn2mods( ...@@ -495,7 +495,7 @@ slap_modrdn2mods(
if( desc->ad_type->sat_equality->smr_normalize) { if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)( (void) (*desc->ad_type->sat_equality->smr_normalize)(
SLAP_MR_EQUALITY, SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
desc->ad_type->sat_syntax, desc->ad_type->sat_syntax,
desc->ad_type->sat_equality, desc->ad_type->sat_equality,
&mod_tmp->sml_values[0], &mod_tmp->sml_values[0],
...@@ -564,7 +564,7 @@ slap_modrdn2mods( ...@@ -564,7 +564,7 @@ slap_modrdn2mods(
if( desc->ad_type->sat_equality->smr_normalize) { if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)( (void) (*desc->ad_type->sat_equality->smr_normalize)(
SLAP_MR_EQUALITY, SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
desc->ad_type->sat_syntax, desc->ad_type->sat_syntax,
desc->ad_type->sat_equality, desc->ad_type->sat_equality,
&mod_tmp->sml_values[0], &mod_tmp->sml_values[0],
......
...@@ -873,9 +873,9 @@ entry_naming_check( ...@@ -873,9 +873,9 @@ entry_naming_check(
} }
if ( value_find_ex( desc, if ( value_find_ex( desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, SLAP_MR_VALUE_OF_ASSERTION_SYNTAX|
attr->a_nvals, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
&ava->la_value, NULL ) != 0 ) attr->a_nvals, &ava->la_value, NULL ) != 0 )
{ {
snprintf( textbuf, textlen, snprintf( textbuf, textlen,
"value of naming attribute '%s' is not present in entry", "value of naming attribute '%s' is not present in entry",
......
...@@ -861,6 +861,8 @@ uniqueMemberNormalize( ...@@ -861,6 +861,8 @@ uniqueMemberNormalize(
struct berval out; struct berval out;
int rc; int rc;
assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ));
ber_dupbv( &out, val ); ber_dupbv( &out, val );
if( out.bv_len != 0 ) { if( out.bv_len != 0 ) {
struct berval uid = { 0, NULL }; struct berval uid = { 0, NULL };
...@@ -1170,6 +1172,8 @@ UTF8StringNormalize( ...@@ -1170,6 +1172,8 @@ UTF8StringNormalize(
int flags; int flags;
int i, wasspace; int i, wasspace;
assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use ));
if( val->bv_val == NULL ) { if( val->bv_val == NULL ) {
/* assume we're dealing with a syntax (e.g., UTF8String) /* assume we're dealing with a syntax (e.g., UTF8String)
* which allows empty strings * which allows empty strings
...@@ -1463,6 +1467,8 @@ telephoneNumberNormalize( ...@@ -1463,6 +1467,8 @@ telephoneNumberNormalize(
{ {
char *p, *q; char *p, *q;
assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ));
/* validator should have refused an empty string */ /* validator should have refused an empty string */
assert( val->bv_len ); assert( val->bv_len );
...@@ -1712,6 +1718,8 @@ IA5StringNormalize( ...@@ -1712,6 +1718,8 @@ IA5StringNormalize(
assert( val->bv_len ); assert( val->bv_len );
assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use ));
p = val->bv_val; p = val->bv_val;
/* Ignore initial whitespace */ /* Ignore initial whitespace */
...@@ -2119,11 +2127,12 @@ certificateExactNormalize( ...@@ -2119,11 +2127,12 @@ certificateExactNormalize(
if( val->bv_len == 0 ) goto done; if( val->bv_len == 0 ) goto done;
if( val->bv_val[0] != LBER_SEQUENCE ) { if( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX(usage) ) {
/* assume serialNumberAndIssuer */
return serialNumberAndIssuerNormalize(0,NULL,NULL,val,normalized,ctx); return serialNumberAndIssuerNormalize(0,NULL,NULL,val,normalized,ctx);
} }
assert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) );
p = val->bv_val; p = val->bv_val;
xcert = d2i_X509( NULL, &p, val->bv_len); xcert = d2i_X509( NULL, &p, val->bv_len);
if( xcert == NULL ) goto done; if( xcert == NULL ) goto done;
......
...@@ -451,11 +451,18 @@ typedef struct slap_matching_rule { ...@@ -451,11 +451,18 @@ typedef struct slap_matching_rule {
*/ */
#define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX 0x0001U #define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX 0x0001U
#define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX 0x0002U #define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX 0x0002U
#define SLAP_MR_VALUE_OF_SYNTAX 0x0003U
#define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \ #define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \
((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX ) ((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX )
#define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \ #define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \
((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX ) ((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX )
#ifdef LDAP_DEBUG
#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) \
((usage) & SLAP_MR_VALUE_OF_SYNTAX)
#else
#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) (1)
#endif
/* either or both the asserted value or attribute value /* either or both the asserted value or attribute value
* may be provided in normalized form * may be provided in normalized form
......
...@@ -163,7 +163,8 @@ int asserted_value_validate_normalize( ...@@ -163,7 +163,8 @@ int asserted_value_validate_normalize(
} }
if( mr->smr_normalize ) { if( mr->smr_normalize ) {
rc = (mr->smr_normalize)( usage, rc = (mr->smr_normalize)(
usage|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
ad ? ad->ad_type->sat_syntax : NULL, ad ? ad->ad_type->sat_syntax : NULL,
mr, in, out, ctx ); mr, in, out, ctx );
...@@ -238,7 +239,7 @@ int value_find_ex( ...@@ -238,7 +239,7 @@ int value_find_ex(
mr->smr_normalize ) mr->smr_normalize )
{ {
rc = (mr->smr_normalize)( rc = (mr->smr_normalize)(
flags & (SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK), flags & (SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK|SLAP_MR_VALUE_OF_SYNTAX),
ad ? ad->ad_type->sat_syntax : NULL, ad ? ad->ad_type->sat_syntax : NULL,
mr, val, &nval, ctx ); mr, val, &nval, ctx );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment