From 815efedff57e957b197ca46c6d108f6159c2b1a4 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Thu, 26 Aug 2004 05:02:21 +0000 Subject: [PATCH] Fix "FIXME" in slapi_attr_add_value() - store normalized value as well as real value --- servers/slapd/slapi/slapi_utils.c | 36 +++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index ecf6fd7281..5d23e1b648 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -2698,10 +2698,38 @@ Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr ) int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v ) { #ifdef LDAP_SLAPI - /* - * FIXME: here we may lose alignment between a_vals/a_nvals - */ - return value_add_one( &a->a_vals, (Slapi_Value *)v ); + struct berval nval; + struct berval *nvalp; + int rc; + AttributeDescription *desc = a->a_desc; + + if ( desc->ad_type->sat_equality && + desc->ad_type->sat_equality->smr_normalize ) { + rc = (*desc->ad_type->sat_equality->smr_normalize)( + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, + desc->ad_type->sat_syntax, + desc->ad_type->sat_equality, + (Slapi_Value *)v, &nval, NULL ); + if ( rc != LDAP_SUCCESS ) { + return rc; + } + nvalp = &nval; + } else { + nvalp = NULL; + } + + rc = value_add_one( &a->a_vals, (Slapi_Value *)v ); + if ( rc == 0 && nvalp != NULL ) { + rc = value_add_one( &a->a_nvals, nvalp ); + } else { + a->a_nvals = a->a_vals; + } + + if ( nvalp != NULL ) { + slapi_ch_free_string( &nval.bv_val ); + } + + return rc; #else return -1; #endif -- 2.39.5