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