From: Howard Chu Date: Mon, 5 Dec 2005 11:46:56 +0000 (+0000) Subject: Fix mod delete by ordered index X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~645 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bb1984eb3e1e93fbdd4e6fb81508aef776cefda6;p=openldap Fix mod delete by ordered index --- diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 54f7eaf296..0d0e7a27df 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -282,7 +282,7 @@ str2entry2( char *s, int checkvals ) * validate value per syntax */ #ifdef SLAP_ORDERED_PRETTYNORM - rc = ordered_value_validate( ad, &vals[i] ); + rc = ordered_value_validate( ad, &vals[i], LDAP_MOD_ADD ); #else /* ! SLAP_ORDERED_PRETTYNORM */ rc = validate( ad->ad_type->sat_syntax, &vals[i] ); #endif /* ! SLAP_ORDERED_PRETTYNORM */ diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index e97c847ac5..116dc3cb17 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -665,7 +665,7 @@ int slap_mods_check( } else { #ifdef SLAP_ORDERED_PRETTYNORM rc = ordered_value_validate( ad, - &ml->sml_values[nvals] ); + &ml->sml_values[nvals], ml->sml_op ); #else /* ! SLAP_ORDERED_PRETTYNORM */ rc = validate( ad->ad_type->sat_syntax, &ml->sml_values[nvals] ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 6f41c2f0b1..e18d9bcca3 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1635,7 +1635,8 @@ LDAP_SLAPD_F (int) ordered_value_add LDAP_P(( LDAP_SLAPD_F (int) ordered_value_validate LDAP_P(( AttributeDescription *ad, - struct berval *in )); + struct berval *in, + int mop )); LDAP_SLAPD_F (int) ordered_value_pretty LDAP_P(( AttributeDescription *ad, diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 2a544c050c..e81a72ed5d 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -409,12 +409,13 @@ ordered_value_sort( Attribute *a, int do_renumber ) /* * wrapper for validate function * uses the validate function of the syntax after removing - * the index, if allowed an present + * the index, if allowed and present */ int ordered_value_validate( AttributeDescription *ad, - struct berval *in ) + struct berval *in, + int mop ) { struct berval bv = *in; @@ -435,6 +436,9 @@ ordered_value_validate( 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; } } @@ -544,6 +548,11 @@ ordered_value_normalize( 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; } }