]> git.sur5r.net Git - openldap/commitdiff
Fix mod delete by ordered index
authorHoward Chu <hyc@openldap.org>
Mon, 5 Dec 2005 11:46:56 +0000 (11:46 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 5 Dec 2005 11:46:56 +0000 (11:46 +0000)
servers/slapd/entry.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/value.c

index 54f7eaf296342e4ef4e7aba32484d6e4ef145139..0d0e7a27dfa4754555331662e0dc8e69598c5c22 100644 (file)
@@ -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 */
index e97c847ac5092dd3a6e2fdab4ee998a74e3d1ac4..116dc3cb17ca68280cbb01fcff74d6bc3fd278ae 100644 (file)
@@ -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] );
index 6f41c2f0b1d7154c313d8a9729693f7fe48f51dd..e18d9bcca3315c6f8cc0c2ea49e73309ebf5ad7a 100644 (file)
@@ -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,
index 2a544c050c0bcaba7538c50e94973d0610ce8f93..e81a72ed5deb7a17a765a21904acef477396319f 100644 (file)
@@ -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;
                }
        }