]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/add.c
check consistency of referrals and result code (ITS#4861)
[openldap] / servers / slapd / add.c
index bacbe232a3a174d07288a0f6cbbd3e40830a3aa2..8d22d54afc255c11b7a4279192511b2cc75d4713 100644 (file)
@@ -1,7 +1,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
@@ -157,7 +157,7 @@ do_add( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       rs->sr_err = slap_mods_check( modlist, &rs->sr_text,
+       rs->sr_err = slap_mods_check( op, modlist, &rs->sr_text,
                textbuf, textlen, NULL );
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -323,15 +323,6 @@ fe_op_add( Operation *op, SlapReply *rs )
                                        goto done;
                                }
 
-#if 0                  /* This is a no-op since *modtail is NULL */
-                               rs->sr_err = slap_mods2entry( *modtail, &op->ora_e,
-                                       0, 0, &rs->sr_text, textbuf, textlen );
-                               if ( rs->sr_err != LDAP_SUCCESS ) {
-                                       send_ldap_result( op, rs );
-                                       goto done;
-                               }
-#endif
-
                                cb.sc_next = op->o_callback;
                                op->o_callback = &cb;
                        }
@@ -472,44 +463,6 @@ slap_mods2entry(
 #endif
                }
 
-#if 0  /* checked for duplicates in slap_mods_check */
-               if( mods->sml_values[1].bv_val != NULL ) {
-                       /* check for duplicates */
-                       int             i, j, rc, match;
-                       MatchingRule *mr = mods->sml_desc->ad_type->sat_equality;
-
-                       for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) {
-                               /* test asserted values against themselves */
-                               for( j = 0; j < i; j++ ) {
-                                       rc = ordered_value_match( &match, mods->sml_desc, mr,
-                                               SLAP_MR_EQUALITY
-                                               | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
-                                               | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
-                                               | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
-                                               mods->sml_nvalues
-                                                       ? &mods->sml_nvalues[i]
-                                                       : &mods->sml_values[i],
-                                               mods->sml_nvalues
-                                                       ? &mods->sml_nvalues[j]
-                                                       : &mods->sml_values[j],
-                                               text );
-
-                                       if ( rc == LDAP_SUCCESS && match == 0 ) {
-                                               /* value exists already */
-                                               snprintf( textbuf, textlen,
-                                                       "%s: value #%d provided more than once",
-                                                       mods->sml_desc->ad_cname.bv_val, j );
-                                               *text = textbuf;
-                                               return LDAP_TYPE_OR_VALUE_EXISTS;
-
-                                       } else if ( rc != LDAP_SUCCESS ) {
-                                               return rc;
-                                       }
-                               }
-                       }
-               }
-#endif
-
                attr = attr_alloc( mods->sml_desc );
 
                /* move values to attr structure */
@@ -655,10 +608,9 @@ int slap_add_opattrs(
                }
                ptr = ber_bvchr( &csn, '#' );
                if ( ptr ) {
-                       timestamp.bv_len = ptr - csn.bv_val;
-                       if ( timestamp.bv_len >= sizeof(timebuf) )      /* ?!? */
-                               timestamp.bv_len = sizeof(timebuf) - 1;
+                       timestamp.bv_len = STRLENOF("YYYYMMDDHHMMSSZ");
                        AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len );
+                       timebuf[timestamp.bv_len-1] = 'Z';
                        timebuf[timestamp.bv_len] = '\0';
                } else {
                        time_t now = slap_get_time();