]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/value.c
further clarify size limit related issues in sync replication (ITS#5243)
[openldap] / servers / slapd / value.c
index 9ccdf5c0533558386f4f8eb8fe944a673bd15717..edeaff12e812694f9b5181beaffbf46901f3663d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@ value_add(
                for ( n = 0; !BER_BVISNULL( &(*vals)[n] ); n++ ) {
                        ;       /* Empty */
                }
-               *vals = (BerVarray) SLAP_REALLOC( (char *) *vals,
+               *vals = (BerVarray) ch_realloc( (char *) *vals,
                    (n + nn + 1) * sizeof(struct berval) );
                if( *vals == NULL ) {
                        Debug(LDAP_DEBUG_TRACE,
@@ -105,7 +105,7 @@ value_add_one(
                for ( n = 0; !BER_BVISNULL( &(*vals)[n] ); n++ ) {
                        ;       /* Empty */
                }
-               *vals = (BerVarray) SLAP_REALLOC( (char *) *vals,
+               *vals = (BerVarray) ch_realloc( (char *) *vals,
                    (n + 2) * sizeof(struct berval) );
                if( *vals == NULL ) {
                        Debug(LDAP_DEBUG_TRACE,
@@ -153,8 +153,12 @@ int asserted_value_validate_normalize(
                rc = (mr->smr_syntax->ssyn_pretty)( mr->smr_syntax, in, &pval, ctx );
                in = &pval;
 
-       } else {
+       } else if ( mr->smr_syntax->ssyn_validate ) {
                rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
+
+       } else {
+               *text = "inappropriate matching request";
+               return LDAP_INAPPROPRIATE_MATCHING;
        }
 
        if( rc != LDAP_SUCCESS ) {
@@ -693,7 +697,21 @@ ordered_value_add(
        }
 
        new = ch_malloc( (anum+vnum+1) * sizeof(struct berval));
-       if ( a->a_nvals && a->a_nvals != a->a_vals ) {
+
+       /* sanity check: if normalized modifications come in, either
+        * no values are present or normalized existing values differ
+        * from non-normalized; if no normalized modifications come in,
+        * either no values are present or normalized existing values
+        * don't differ from non-normalized */
+       if ( nvals != NULL ) {
+               assert( nvals != vals );
+               assert( a->a_nvals == NULL || a->a_nvals != a->a_vals );
+
+       } else {
+               assert( a->a_nvals == NULL || a->a_nvals == a->a_vals );
+       }
+
+       if ( ( a->a_nvals && a->a_nvals != a->a_vals ) || nvals != NULL ) {
                nnew = ch_malloc( (anum+vnum+1) * sizeof(struct berval));
                /* Shouldn't happen... */
                if ( !nvals ) nvals = vals;