X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fadd.c;h=9056e412ae07eda7200489ff8a0ff7b6f64df903;hb=e720c15c4d82d975bf9ce6e7e3a347264d8b0d8d;hp=eb0af1569b42c386ccbf24e5ee6b536084b162a0;hpb=a9067fc056422f91a9bea1efb8afa8058306d2b3;p=openldap diff --git a/servers/slapd/add.c b/servers/slapd/add.c index eb0af1569b..9056e412ae 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,8 @@ do_add( Operation *op, SlapReply *rs ) Modifications tmp; char textbuf[ SLAP_TEXT_BUFLEN ]; size_t textlen = sizeof( textbuf ); - int rc = 1; + int rc = 0; + int freevals = 1; Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 ); /* @@ -175,6 +176,8 @@ do_add( Operation *op, SlapReply *rs ) goto done; } + freevals = 0; + op->o_bd = frontendDB; rc = frontendDB->be_add( op, rs ); if ( rc == 0 ) { @@ -194,12 +197,6 @@ do_add( Operation *op, SlapReply *rs ) done:; if ( modlist != NULL ) { - int freevals = 0; - - if ( rc != 0 && op->ora_e == NULL ) { - freevals = 1; - } - /* in case of error, free the values as well */ slap_mods_free( modlist, freevals ); } @@ -217,10 +214,9 @@ int fe_op_add( Operation *op, SlapReply *rs ) { int manageDSAit; - Modifications *modlist = op->ora_modlist; - Modifications **modtail = &modlist; + Modifications **modtail = &op->ora_modlist; int rc = 0; - BackendDB *op_be; + BackendDB *op_be; char textbuf[ SLAP_TEXT_BUFLEN ]; size_t textlen = sizeof( textbuf ); @@ -271,7 +267,7 @@ fe_op_add( Operation *op, SlapReply *rs ) goto done; } - rs->sr_err = slap_mods_obsolete_check( op, modlist, + rs->sr_err = slap_mods_obsolete_check( op, op->ora_modlist, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { @@ -290,7 +286,7 @@ fe_op_add( Operation *op, SlapReply *rs ) int repl_user = be_isupdate( op ); #ifndef SLAPD_MULTIMASTER if ( !SLAP_SHADOW(op->o_bd) || repl_user ) -#endif +#endif /* ! SLAPD_MULTIMASTER */ { int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; @@ -298,7 +294,7 @@ fe_op_add( Operation *op, SlapReply *rs ) op->o_bd = op_be; if ( !update ) { - rs->sr_err = slap_mods_no_user_mod_check( op, modlist, + rs->sr_err = slap_mods_no_user_mod_check( op, op->ora_modlist, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { @@ -309,7 +305,7 @@ fe_op_add( Operation *op, SlapReply *rs ) if ( !repl_user ) { /* go to the last mod */ - for ( modtail = &modlist; + for ( modtail = &op->ora_modlist; *modtail != NULL; modtail = &(*modtail)->sml_next ) { @@ -320,7 +316,7 @@ fe_op_add( Operation *op, SlapReply *rs ) /* check for duplicate values */ rs->sr_err = slap_mods_no_repl_user_mod_check( op, - modlist, &rs->sr_text, textbuf, textlen ); + op->ora_modlist, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); goto done; @@ -336,7 +332,7 @@ fe_op_add( Operation *op, SlapReply *rs ) #ifdef SLAPD_MULTIMASTER if ( !repl_user ) -#endif +#endif /* SLAPD_MULTIMASTER */ { cb.sc_next = op->o_callback; op->o_callback = &cb; @@ -473,6 +469,7 @@ slap_mods2entry( snprintf( textbuf, textlen, "attribute '%s' provided more than once", mods->sml_desc->ad_cname.bv_val ); + *text = textbuf; return LDAP_TYPE_OR_VALUE_EXISTS; #endif } @@ -503,6 +500,7 @@ slap_mods2entry( 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 ) { @@ -667,12 +665,12 @@ int slap_add_opattrs( } else { csn = op->o_csn; } - ptr = strchr( csn.bv_val, '#' ); + ptr = ber_bvchr( &csn, '#' ); if ( ptr ) { timestamp.bv_len = ptr - csn.bv_val; - if ( timestamp.bv_len >= sizeof(timebuf) ) + if ( timestamp.bv_len >= sizeof(timebuf) ) /* ?!? */ timestamp.bv_len = sizeof(timebuf) - 1; - strncpy( timebuf, csn.bv_val, timestamp.bv_len ); + AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len ); timebuf[timestamp.bv_len] = '\0'; } else { time_t now = slap_get_time(); @@ -736,7 +734,6 @@ int slap_add_opattrs( attr_merge_one( op->ora_e, slap_schema.si_ad_modifyTimestamp, ×tamp, NULL ); } - } return LDAP_SUCCESS; }